Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 617FE431FBC for ; Sat, 28 Jan 2012 21:50:17 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 64oBZNsTE7Wg for ; Sat, 28 Jan 2012 21:50:16 -0800 (PST) Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU [18.7.68.35]) by olra.theworths.org (Postfix) with ESMTP id 520C6431FD2 for ; Sat, 28 Jan 2012 21:50:16 -0800 (PST) X-AuditID: 12074423-b7f9c6d0000008c3-84-4f24de165507 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id BC.EA.02243.61ED42F4; Sun, 29 Jan 2012 00:50:15 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q0T5oEnN009502; Sun, 29 Jan 2012 00:50:14 -0500 Received: from drake.mit.edu (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0T5oCF4028023 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 29 Jan 2012 00:50:13 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1RrNeV-0007ab-Vk; Sun, 29 Jan 2012 00:50:12 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 1/3] lib: Don't delete uninitialized pointers Date: Sun, 29 Jan 2012 00:50:08 -0500 Message-Id: <1327816210-29124-1-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsUixG6nrit+T8Xf4PFrRovrN2cyOzB6PFt1 izmAMYrLJiU1J7MstUjfLoEr49S8+ywFk9krXnXfYmlgfMXaxcjJISFgInFm3U8mCFtM4sK9 9WxdjFwcQgL7GCWu/F3KCOFsYJTYe/szVOY+k8Tv2c9ZIJz5jBJN65Yxg/SzCWhIbNu/nBHE FhGQlth5dzbQDg4OZgE1iT9dKl2M7BzCArYS781AClgEVCWunLjKBmLzCjhIHOu4wAhxhILE udXn2Ccw8i5gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka6aXm1mil5pSuokRHAIuyjsY/xxU OsQowMGoxMOrsELFX4g1say4MvcQoyQHk5Io74I7QCG+pPyUyozE4oz4otKc1OJDjBIczEoi vI4zgXK8KYmVValF+TApaQ4WJXFeDa13fkIC6YklqdmpqQWpRTBZGQ4OJQneuLtAjYJFqemp FWmZOSUIaSYOTpDhPEDDPUBqeIsLEnOLM9Mh8qcYFaXEef1BEgIgiYzSPLheWIy+YhQHekWY 1wekigcY33Ddr4AGMwENjriqCDK4JBEhJdXAuNVcd1Wm9XOm31Mbpz842Zqw5LN6z3KOa+ly C/n++CxIT02fo5VhJN9Wyz/x0eO0OfsSZuvdvffkpnev5GZJ9cAF114yvJfwzH6QW5iw6tzH tdcceuZesWpZId4b3y+yrtZMeHvzJeM/Wxad+z2F+fjv9ZtdRF2XT9s86+fzrxZCx/8wVJ0S OaHEUpyRaKjFXFScCABi/HHjrAIAAA== X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jan 2012 05:50:17 -0000 In the error-handling paths of notmuch_database_open, we call notmuch_database_close, which "delete"s several objects referenced by the notmuch_database_t object. However, some of these pointers may be uninitialized, resulting in undefined behavior. Hence, allocate the notmuch_database_t with talloc_zero to make sure these pointers are NULL so that "delete"ing them is harmless. --- lib/database.cc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 8103bd9..a6d15a1 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -617,7 +617,7 @@ notmuch_database_open (const char *path, initialized = 1; } - notmuch = talloc (NULL, notmuch_database_t); + notmuch = talloc_zero (NULL, notmuch_database_t); notmuch->exception_reported = FALSE; notmuch->path = talloc_strdup (notmuch, path); -- 1.7.7.3