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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
cc5e1bf992
commit
0210231b08
@ -159,18 +159,23 @@ static void init_gettext_charset(const char *domain)
|
|||||||
void git_setup_gettext(void)
|
void git_setup_gettext(void)
|
||||||
{
|
{
|
||||||
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
|
const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
|
||||||
|
char *p = NULL;
|
||||||
|
|
||||||
if (!podir)
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bindtextdomain("git", podir);
|
bindtextdomain("git", podir);
|
||||||
setlocale(LC_MESSAGES, "");
|
setlocale(LC_MESSAGES, "");
|
||||||
setlocale(LC_TIME, "");
|
setlocale(LC_TIME, "");
|
||||||
init_gettext_charset("git");
|
init_gettext_charset("git");
|
||||||
textdomain("git");
|
textdomain("git");
|
||||||
|
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the number of columns of string 's' in current locale */
|
/* return the number of columns of string 's' in current locale */
|
||||||
|
Loading…
Reference in New Issue
Block a user