[PATCH 2/2] lib: introduce notmuch_database_new for initializing a database handle
[notmuch-archives.git] / bc / 44c01a585e18630814084c0b9f616cb6ace995
1 Return-Path: <teythoon@jade-hamburg.de>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id EAAF6429E26\r
6         for <notmuch@notmuchmail.org>; Mon, 24 Sep 2012 08:21:47 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 5fls1yN9yLft for <notmuch@notmuchmail.org>;\r
16         Mon, 24 Sep 2012 08:21:47 -0700 (PDT)\r
17 Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 6CF40431FC7\r
21         for <notmuch@notmuchmail.org>; Mon, 24 Sep 2012 08:21:44 -0700 (PDT)\r
22 Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228])\r
23         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
24         (No client certificate requested)\r
25         by mail.cryptobitch.de (Postfix) with ESMTPSA id 4BCD05AB296\r
26         for <notmuch@notmuchmail.org>; Mon, 24 Sep 2012 17:21:43 +0200 (CEST)\r
27 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
28         id BDCEEDF2A2; Mon, 24 Sep 2012 17:21:42 +0200 (CEST)\r
29 Received: from thinkbox.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228])\r
30         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
31         (No client certificate requested) (Authenticated sender: teythoon)\r
32         by mail.jade-hamburg.de (Postfix) with ESMTPSA id 202F5DF2A6;\r
33         Mon, 24 Sep 2012 17:21:32 +0200 (CEST)\r
34 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80)\r
35         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
36         id 1TGATR-0007lN-2R; Mon, 24 Sep 2012 17:21:29 +0200\r
37 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 6/6] Avoid potentially dereferencing a NULL pointer\r
40 Date: Mon, 24 Sep 2012 17:21:20 +0200\r
41 Message-Id:\r
42  <1348500080-29726-6-git-send-email-4winter@informatik.uni-hamburg.de>\r
43 X-Mailer: git-send-email 1.7.10.4\r
44 In-Reply-To:\r
45  <1348500080-29726-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
46 References: <873927eb5i.fsf@convex-new.cs.unb.ca>\r
47         <1348500080-29726-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Mon, 24 Sep 2012 15:21:48 -0000\r
61 \r
62 GMIME_IS_MULTIPART and GMIME_IS_MESSAGE both handle NULL pointers\r
63 gracefully, but the G_OBJECT_TYPE used in the error handling block\r
64 dereferences it without checking it first.\r
65 \r
66 Fix this by checking whether parent->part is valid.\r
67 \r
68 Found using the clang static analyzer.\r
69 \r
70 Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>\r
71 ---\r
72  mime-node.c |    2 +-\r
73  1 file changed, 1 insertion(+), 1 deletion(-)\r
74 \r
75 diff --git a/mime-node.c b/mime-node.c\r
76 index 97e8b48..839737a 100644\r
77 --- a/mime-node.c\r
78 +++ b/mime-node.c\r
79 @@ -291,7 +291,7 @@ mime_node_child (mime_node_t *parent, int child)\r
80      GMimeObject *sub;\r
81      mime_node_t *node;\r
82  \r
83 -    if (!parent || child < 0 || child >= parent->nchildren)\r
84 +    if (!parent || !parent->part || child < 0 || child >= parent->nchildren)\r
85         return NULL;\r
86  \r
87      if (GMIME_IS_MULTIPART (parent->part)) {\r
88 -- \r
89 1.7.10.4\r
90 \r