]> git.notmuchmail.org Git - notmuch/commitdiff
Avoid potentially dereferencing a NULL pointer
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Mon, 24 Sep 2012 15:21:20 +0000 (17:21 +0200)
committerDavid Bremner <bremner@debian.org>
Thu, 27 Sep 2012 15:52:34 +0000 (12:52 -0300)
GMIME_IS_MULTIPART and GMIME_IS_MESSAGE both handle NULL pointers
gracefully, but the G_OBJECT_TYPE used in the error handling block
dereferences it without checking it first.

Fix this by checking whether parent->part is valid.

Found using the clang static analyzer.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
mime-node.c

index 97e8b480271210db3489f74c3b17e10a139407f4..839737a8b354df36cec7f0bcea9ca05188618fcb 100644 (file)
@@ -291,7 +291,7 @@ mime_node_child (mime_node_t *parent, int child)
     GMimeObject *sub;
     mime_node_t *node;
 
-    if (!parent || child < 0 || child >= parent->nchildren)
+    if (!parent || !parent->part || child < 0 || child >= parent->nchildren)
        return NULL;
 
     if (GMIME_IS_MULTIPART (parent->part)) {