]> git.notmuchmail.org Git - notmuch/commitdiff
Do not segfault on empty mime parts
authormartin f. krafft <madduck@madduck.net>
Tue, 2 Mar 2010 15:31:28 +0000 (16:31 +0100)
committerCarl Worth <cworth@cworth.org>
Tue, 13 Apr 2010 15:49:06 +0000 (08:49 -0700)
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>
lib/index.cc

index cf930251c8c7be4c34bb53dab6930cca940d0302..0d6640bce57e59a657f6d7287d68aac535bd5534 100644 (file)
@@ -336,6 +336,11 @@ _index_mime_part (notmuch_message_t *message,
     GMimeContentDisposition *disposition;
     char *body;
 
     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;
     if (GMIME_IS_MULTIPART (part)) {
        GMimeMultipart *multipart = GMIME_MULTIPART (part);
        int i;