From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wIgBECEjX2AzNwAAgWs5BA (envelope-from ) for ; Sat, 27 Mar 2021 13:20:49 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id aHDgCiEjX2BhCAAA1q6Kng (envelope-from ) for ; Sat, 27 Mar 2021 12:20:49 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7C5051B43F for ; Sat, 27 Mar 2021 13:20:48 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CADEF2757B; Sat, 27 Mar 2021 08:20:40 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 79C941FD22 for ; Sat, 27 Mar 2021 08:20:37 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id C93F15FA96; Sat, 27 Mar 2021 08:20:35 -0400 (EDT) Received: (nullmailer pid 526761 invoked by uid 1000); Sat, 27 Mar 2021 12:20:34 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH] lib/open: fix leaks calling _trial_open Date: Sat, 27 Mar 2021 09:20:28 -0300 Message-Id: <20210327122028.526710-1-david@tethera.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Message-ID-Hash: 7MQCV7INAKDS4T4JGC2EAWDUGETNAULY X-Message-ID-Hash: 7MQCV7INAKDS4T4JGC2EAWDUGETNAULY X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616847648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qnLatb5I6GUkAi0iZMrq6GucrOV06BoX3jNryNL5g2E=; b=kiDq2rX9JH9Y2wkq5Nxp+UDRiSHq6mRx3cb+0QJSY5yhjF4zZt5PVyOHLdxSypXJyIopmh h3/Hht+mRy4aAwFFcUo/4m7WDq9k+eBG9hEIV9WYPxD0xUestqdh7H2TKVb0ljFIcKc52g 7Gv0fHsKK6SjluvwLlkVUcj/duXyOzwOBUjUFbieIblmkSL0MEK47hyWY3VyYIHpavo4Ni kRPoBC393biEti5FinR+C0/eq6bGKfYv3tc44fjuEzCNAPFslEc65phvnZlGlrHkunLeoV NbUikw19wgg2deDGYQqAK3uPUAViEknNd45umHYb+UjZ3nJcWrpDSNu6V7d+VQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616847648; a=rsa-sha256; cv=none; b=WUGduR/k5G8Xece+LCngCl8SvbA8v+somZ01APRpzBE1AqK3tNBlcJUqOnkR3oTzq9ozXT tQT0kxXdlS/T/Ed0apEJZWeZdQLnaa8lATJljPN7JjluV3grCCvQ108hr6NOgOWiU0A3Sm +p4WkZkz8llenrfUepdWXl1PKGey7XkBizgGO5Q9zLZIFKEpOt2YZO2ur35boj6BTXKc5h 3QGGvepQQB9zrZBbYOl3lVRzx+EMHKnXooPz650tks4ACwjzOEVFUw+O4WubvPisiBB9SP WwVbqTmRhraZmMlL2hPUg9fbKWMeXU6ThOKzzxORPoDSYE2crLInzBobeANhSQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.11 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 7C5051B43F X-Spam-Score: -1.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: XA8ei4uJHSE1 _trial_open can't know if the PATH_ERROR return value will cause the error message to be returned from the library, so it's up the caller to clean up if not. --- lib/open.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/open.cc b/lib/open.cc index 8f572b0b..dc191d64 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -280,6 +280,9 @@ _notmuch_choose_xapian_path (void *ctx, const char *database_path, if (status != NOTMUCH_STATUS_PATH_ERROR) goto DONE; + if (*message_ptr) + free (*message_ptr); + notmuch_path = talloc_asprintf (ctx, "%s/.notmuch", database_path); status = _db_dir_exists (notmuch_path, message_ptr); if (status) @@ -648,6 +651,9 @@ notmuch_database_create_with_config (const char *database_path, goto DONE; } + if (message) + free (message); + status = _finish_open (notmuch, profile, NOTMUCH_DATABASE_MODE_READ_WRITE, -- 2.30.2