Skip to content

Commit 0735d74

Browse files
committed
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]>
1 parent 6c28c81 commit 0735d74

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
@@ -161,18 +161,23 @@ static void init_gettext_charset(const char *domain)
161161
void git_setup_gettext(void)
162162
{
163163
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
164+
char *p = NULL;
164165

165166
if (!podir)
166-
podir = system_path(GIT_LOCALE_PATH);
167+
podir = p = system_path(GIT_LOCALE_PATH);
167168

168-
if (!is_directory(podir))
169+
if (!is_directory(podir)) {
170+
free(p);
169171
return;
172+
}
170173

171174
bindtextdomain("git", podir);
172175
setlocale(LC_MESSAGES, "");
173176
setlocale(LC_TIME, "");
174177
init_gettext_charset("git");
175178
textdomain("git");
179+
180+
free(p);
176181
}
177182

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

0 commit comments

Comments
 (0)