From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 7VUvM7YRbWAyIQEAgWs5BA (envelope-from ) for ; Wed, 07 Apr 2021 03:58:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id cIsyLLYRbWCVRwAAB5/wlQ (envelope-from ) for ; Wed, 07 Apr 2021 01:58:14 +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 55E1DAEBA for ; Wed, 7 Apr 2021 03:58:14 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D8717290D1; Tue, 6 Apr 2021 21:56:53 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 08E2529052 for ; Tue, 6 Apr 2021 21:56:05 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id F396A5FA96; Tue, 6 Apr 2021 21:56:04 -0400 (EDT) Received: (nullmailer pid 2964204 invoked by uid 1000); Wed, 07 Apr 2021 01:55:35 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 01/28] lib/open: fix leaks calling _trial_open Date: Tue, 6 Apr 2021 22:55:03 -0300 Message-Id: <20210407015530.2964017-2-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210407015530.2964017-1-david@tethera.net> References: <20210407015530.2964017-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 4KRIUEZJIN6UZAFD7SLT3UPSSJDCAZLS X-Message-ID-Hash: 4KRIUEZJIN6UZAFD7SLT3UPSSJDCAZLS 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=1617760694; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qnLatb5I6GUkAi0iZMrq6GucrOV06BoX3jNryNL5g2E=; b=Fe4nUDYv4OyaWtPVtfvsbri1BuDO3AuxnP4IF98YbgUbVhO9d9d0T4LXyqmtqGxEt3US0J cWLo2AEyYf5c5QKd2xLiJRCvxw0yzQNk0d8PREQpqg7mtXwBSskTRVakxS8BUHIGcZIUbv X5fSBJUb1dD2sF19wpiX7rxevY48ALl5YvgWYBVuVniFDArGIiM9aPu4wI3Jn0W2qoulCv pTsOZe0pOeVbpr4rouxKnsxIU7qY3cRnU3x/wId96b5C1+elrNwx9EZ85/2EsoveTRkIfd Wz0IJn8/jshgWDmiISBpwE2kBr95dSuCx4AOaWQUJ33l7aDXoCp/qVMJvTvqUQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617760694; a=rsa-sha256; cv=none; b=fNVH3OcOEnz0r7oalpzYuXQ6p74FfuuaoXU6zcnC/SQb7arju4TB96m584d0rjha3zr9+U o1J+QH+zAkOyMr3jtsHz7r/3jf8YNrhasKqeConNEvxVOW8fppExpKCrs2CoYdSa6rrzN1 2aCbgLZfEKSVWLoWwrB385hhqhbrVtl4ZAeSbolaKZT9IKsLrdVQvpe6qpkPEF/gVrGLu0 X6Mfvd0Wl3cx4kR2UsTD4cUoHRSBsviDtSQKQILzlsYpzS/n6EBNSdzkA4rILRyQIKBl/t tSqIipcl4QkVOEvW5J21qtGhnfkQk67xqWKDS0obYSt+F41097JDeS2RreX/VA== 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: -0.88 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: 55E1DAEBA X-Spam-Score: -0.88 X-Migadu-Scanner: scn0.migadu.com X-TUID: 9ZGteZxejpHy _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