int mime_length;
char mime_http[SIZ];
char *attachments = NULL;
+ char *ptr = NULL;
int num_attachments = 0;
struct wc_attachment *att, *aptr;
char m_subject[256];
* yet because we're in the middle of a server transaction.
*/
if (!strncasecmp(buf, "part=", 5)) {
- ++num_attachments;
- attachments = realloc(attachments, (num_attachments * 1024));
- strcat(attachments, &buf[5]);
- strcat(attachments, "\n");
+ ptr = realloc(attachments, ((num_attachments+1) * 1024));
+ if (ptr != NULL) {
+ ++num_attachments;
+ attachments = ptr;
+ strcat(attachments, &buf[5]);
+ strcat(attachments, "\n");
+ }
}
}
}
}
- free(attachments);
+ if (attachments != NULL) {
+ free(attachments);
+ }
}
#ifdef HAVE_ICONV