Do not segfault on empty mime parts

notmuch previously unconditionally checked mime parts for various
properties, but not for NULL, which is the case if libgmime encounters
an empty mime part.

Upon encounter of an empty mime part, the following is printed to
stderr (the second line due to my patch):

  (process:17197): gmime-CRITICAL **: g_mime_message_get_mime_part: assertion `GMIME_IS_MESSAGE (message)' failed
  Warning: Not indexing empty mime part.

This is probably a bug that should get addressed in libgmime, but for
not, my patch is an acceptable workaround.

Signed-off-by: martin f. krafft <madduck@madduck.net>
This commit is contained in:
martin f. krafft 2010-03-02 16:31:28 +01:00 committed by Carl Worth
parent 4234215263
commit 449a418c65

View file

@ -336,6 +336,11 @@ _index_mime_part (notmuch_message_t *message,
GMimeContentDisposition *disposition;
char *body;
if (! part) {
fprintf (stderr, "Warning: Not indexing empty mime part.\n");
return;
}
if (GMIME_IS_MULTIPART (part)) {
GMimeMultipart *multipart = GMIME_MULTIPART (part);
int i;