[PATCH v2 04/11] lib: do not leak the database in compaction
authorJani Nikula <jani@nikula.org>
Sun, 3 Nov 2013 12:24:44 +0000 (14:24 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:57:57 +0000 (09:57 -0800)
ca/76b0457004fddafcf0ea3d46401bbb56e8e8dd [new file with mode: 0644]

diff --git a/ca/76b0457004fddafcf0ea3d46401bbb56e8e8dd b/ca/76b0457004fddafcf0ea3d46401bbb56e8e8dd
new file mode 100644 (file)
index 0000000..7aeee0f
--- /dev/null
@@ -0,0 +1,98 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1CD72429E3C\r
+       for <notmuch@notmuchmail.org>; Sun,  3 Nov 2013 04:25:19 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ZOzV-DC19HHu for <notmuch@notmuchmail.org>;\r
+       Sun,  3 Nov 2013 04:25:13 -0800 (PST)\r
+Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com\r
+ [74.125.83.42])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 75BC1431FDA   for <notmuch@notmuchmail.org>; Sun,  3 Nov 2013 04:25:05 -0800\r
+ (PST)\r
+Received: by mail-ee0-f42.google.com with SMTP id c1so184358eek.1\r
+       for <notmuch@notmuchmail.org>; Sun, 03 Nov 2013 04:25:04 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=Q18zapYhmVYbh+wYHUDDutg6DE8zQhpUDFrY2a3Qmas=;\r
+       b=iEz6jU7Nn/OeaUBkLuU/Iub0cig8ysC33rdrDdiHYEQQZxwcVSG8wTB2dBxsU4ZfCB\r
+       z6v7WUsWxCCofAFLa7achwP1nD7vAKxG3L1/vJSR2vuTiDfR+9Lk7WTR+Dv3vPmDm/X0\r
+       nHnJjnWW6lvBUdxPUZeJ4QBhw5/+34rF3PzAVfiWcdOjRBJQGAHoJE/yItCyhpxGAqFT\r
+       gZ5vRG+OEiBB7bIaiv9iw6xIu+81kbgHNExzQnqYwT8e42gz5XDflI2O73Wl6h9UpFfe\r
+       G9g4bwGu9blbwPp2ScI6Sd7VmesrrXPFA8vJadNjSEqbOZF1RbMR5lsKJYTO1Bfw61Qo\r
+       dECw==\r
+X-Gm-Message-State:\r
+ ALoCoQnsDSJJyXABn9et6tceEm+D/4i0Nd11Zx8f7SoM/Cs43hXxOghQRnyxKeYUkI+F5oYtfFq/\r
+X-Received: by 10.15.111.202 with SMTP id cj50mr145983eeb.71.1383481504302;\r
+       Sun, 03 Nov 2013 04:25:04 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id i1sm32877757eeg.0.2013.11.03.04.25.02\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 03 Nov 2013 04:25:03 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 04/11] lib: do not leak the database in compaction\r
+Date: Sun,  3 Nov 2013 14:24:44 +0200\r
+Message-Id:\r
+ <c795ec768c882b9f5b8d3b33492e4a8ad3a9284a.1383481295.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
+References: <cover.1383481295.git.jani@nikula.org>\r
+In-Reply-To: <cover.1383481295.git.jani@nikula.org>\r
+References: <cover.1383481295.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 03 Nov 2013 12:25:19 -0000\r
+\r
+Destroy instead of close the database after compaction, and also on\r
+error path, to not leak the database.\r
+---\r
+ lib/database.cc | 6 ++++--\r
+ 1 file changed, 4 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 7a8702e..eadf8a7 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -941,10 +941,12 @@ notmuch_database_compact (const char* path,\r
+       goto DONE;\r
+     }\r
\r
+-    notmuch_database_close(notmuch);\r
+-\r
+ DONE:\r
++    if (notmuch)\r
++      notmuch_database_destroy (notmuch);\r
++\r
+     talloc_free(local);\r
++\r
+     return ret;\r
+ }\r
+ #else\r
+-- \r
+1.8.4.rc3\r
+\r