From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Dan Jacques" <dnj@google.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 2/3] git_setup_gettext: plug memory leak
Date: Sat, 21 Apr 2018 13:14:28 +0200 (DST) [thread overview]
Message-ID: <34971f7dd4c4b5df1f7924759d5aee9784c82fc6.1524309209.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <cover.1524309209.git.johannes.schindelin@gmx.de>
The system_path() function returns a freshly-allocated string. We need
to release it.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
gettext.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/gettext.c b/gettext.c
index 701355d66e7..7272771c8e4 100644
--- a/gettext.c
+++ b/gettext.c
@@ -159,18 +159,23 @@ static void init_gettext_charset(const char *domain)
void git_setup_gettext(void)
{
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
+ char *p = NULL;
if (!podir)
- podir = system_path(GIT_LOCALE_PATH);
+ podir = p = system_path(GIT_LOCALE_PATH);
- if (!is_directory(podir))
+ if (!is_directory(podir)) {
+ free(p);
return;
+ }
bindtextdomain("git", podir);
setlocale(LC_MESSAGES, "");
setlocale(LC_TIME, "");
init_gettext_charset("git");
textdomain("git");
+
+ free(p);
}
/* return the number of columns of string 's' in current locale */
--
2.17.0.windows.1.15.gaa56ade3205
next prev parent reply other threads:[~2018-04-21 11:14 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 8:03 [PATCH 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
2018-04-20 8:03 ` [PATCH 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
2018-04-20 9:59 ` Ævar Arnfjörð Bjarmason
2018-04-20 10:54 ` Martin Ågren
2018-04-20 11:18 ` Ævar Arnfjörð Bjarmason
2018-04-20 19:35 ` Johannes Schindelin
2018-04-21 7:43 ` Ævar Arnfjörð Bjarmason
2018-04-21 10:17 ` Johannes Schindelin
2018-04-20 8:03 ` [PATCH 2/3] git_setup_gettext: plug memory leak Johannes Schindelin
2018-04-20 8:04 ` [PATCH 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
2018-04-22 15:32 ` Philip Oakley
2018-04-21 11:13 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Johannes Schindelin
2018-04-21 11:14 ` [PATCH v2 1/3] gettext: avoid initialization if the locale dir is not present Johannes Schindelin
2018-04-21 11:14 ` Johannes Schindelin [this message]
2018-04-21 11:18 ` [PATCH v2 3/3] Avoid multiple PREFIX definitions Johannes Schindelin
2018-04-24 1:44 ` [PATCH v2 0/3] Some add-on patches on top of dj/runtime-prefix Junio C Hamano
2018-04-24 1:50 ` Junio C Hamano
2018-04-24 2:41 ` Junio C Hamano
2018-04-24 14:48 ` Johannes Schindelin
2018-04-25 1:28 ` Junio C Hamano
2018-04-25 7:46 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34971f7dd4c4b5df1f7924759d5aee9784c82fc6.1524309209.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=dnj@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).