Skip to content

Commit 0210231

Browse files
dschogitster
authored andcommitted
git_setup_gettext: plug memory leak
The system_path() function returns a freshly-allocated string. We need to release it. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cc5e1bf commit 0210231

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gettext.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,23 @@ static void init_gettext_charset(const char *domain)
159159
void git_setup_gettext(void)
160160
{
161161
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
162+
char *p = NULL;
162163

163164
if (!podir)
164-
podir = system_path(GIT_LOCALE_PATH);
165+
podir = p = system_path(GIT_LOCALE_PATH);
165166

166-
if (!is_directory(podir))
167+
if (!is_directory(podir)) {
168+
free(p);
167169
return;
170+
}
168171

169172
bindtextdomain("git", podir);
170173
setlocale(LC_MESSAGES, "");
171174
setlocale(LC_TIME, "");
172175
init_gettext_charset("git");
173176
textdomain("git");
177+
178+
free(p);
174179
}
175180

176181
/* return the number of columns of string 's' in current locale */

0 commit comments

Comments
 (0)