From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KOQvGY2IQ2AweQAA0tVLHw (envelope-from ) for ; Sat, 06 Mar 2021 13:50:05 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QMO6FI2IQ2CCIwAAbx9fmQ (envelope-from ) for ; Sat, 06 Mar 2021 13:50:05 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 D08D71537C for ; Sat, 6 Mar 2021 14:50:04 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7E02927585; Sat, 6 Mar 2021 08:49:46 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id CF95C26BF0 for ; Sat, 6 Mar 2021 08:49:40 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id C77BE5FA96; Sat, 6 Mar 2021 08:49:40 -0500 (EST) Received: (nullmailer pid 491404 invoked by uid 1000); Sat, 06 Mar 2021 13:49:37 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 2/4] lib/open: free value from g_key_file_get_value Date: Sat, 6 Mar 2021 09:49:32 -0400 Message-Id: <20210306134934.491249-3-david@tethera.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210306134934.491249-1-david@tethera.net> References: <20210306134934.491249-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: YHNUX5I7C5SAFF5JE2YSHXM2JXFHPZMS X-Message-ID-Hash: YHNUX5I7C5SAFF5JE2YSHXM2JXFHPZMS 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=1615038604; 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=2n1HLIDBl3eaiBI1rhEMWK2321o6BAVNAH+PeqOT+b0=; b=gW6nngKkUoNGYi49LkM6nlA7RhTM0HWgCqrLlvHia6Uy5n7Bi8KT+DH/JB0Y1vAI2m9hvO 3NvBlLEMr4+OPjpnUezIWlzQpZ5zk6A8I42ywEwTw6N+vzm6z3+3eX2XEFWG/ou41gHMV0 6tWUhApW+yVXtYFUTwCwxbTVO17/17Q0aabC8PA49xTQYtczEw//o0ePxCQ/huZZ2cNMNL M/J/eyOuucZhHGlUdml8r4UgcZWYF/awUSdzj0+J++3+nhOSBGM1pAddOdIke3QZ3oDPV5 nEA7WRJiKNG7QfpYKgH7FFwmt2amK7694xL1iTbGzl/SsXYEeDJ51K2yuOKbQQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615038604; a=rsa-sha256; cv=none; b=uIaJi8IhelznGrt0e+IK+S1n6mTyYMQ/ImGhGbMFjVWOKlF4f4Rzb25MgGNzNqpL8Xljmd PIkUChxOsJqQL55MSzplxdFpXDtqWCHziFx9JZokOGli0Y4J5VF3uuaaQgfeQPlpW05koK wsmoSINzM/2WQnHr+pIfwCY0+ieQdtj9cMPsVs1cpgrl7aWe6cqj997mQIkE9DUgzXcvFC QZysUWy5jcyX0ZD31SGOpGQeCnry+Uy/S3W/yNzN06S7+st/jd0DxvXZT+UeBWJtsFQUZI KlnmXeWpZtaTESxHchoWG6nnDmOJM79jbzb6zeLOYiTcayC2B1vzaf7IoKwD2g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.07 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: D08D71537C X-Spam-Score: -1.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: q0fS4YRXt9o9 This fixes a small memory leak. --- lib/open.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/open.cc b/lib/open.cc index 3b66d2eb..b424fa0c 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -153,7 +153,8 @@ DONE: } static notmuch_status_t -_choose_database_path (const char *config_path, +_choose_database_path (void *ctx, + const char *config_path, const char *profile, GKeyFile **key_file, const char **database_path, @@ -167,8 +168,13 @@ _choose_database_path (const char *config_path, return status; } - if (! *database_path && *key_file) - *database_path = g_key_file_get_value (*key_file, "database", "path", NULL); + if (! *database_path && *key_file) { + char *path = g_key_file_get_value (*key_file, "database", "path", NULL); + if (path) { + *database_path = talloc_strdup (ctx, path); + g_free (path); + } + } if (*database_path == NULL) { *message = strdup ("Error: Cannot open a database for a NULL path.\n"); @@ -201,7 +207,7 @@ notmuch_database_open_with_config (const char *database_path, GKeyFile *key_file = NULL; static int initialized = 0; - if ((status = _choose_database_path (config_path, profile, &key_file, &database_path, &message))) + if ((status = _choose_database_path (local, config_path, profile, &key_file, &database_path, &message))) goto DONE; if (! (notmuch_path = talloc_asprintf (local, "%s/%s", database_path, ".notmuch"))) { @@ -425,7 +431,7 @@ notmuch_database_create_with_config (const char *database_path, int err; void *local = talloc_new (NULL); - if ((status = _choose_database_path (config_path, profile, &key_file, &database_path, &message))) + if ((status = _choose_database_path (local, config_path, profile, &key_file, &database_path, &message))) goto DONE; err = stat (database_path, &st); -- 2.30.1