Skip to content

Commit

Permalink
Fix a memory leak
Browse files Browse the repository at this point in the history
Memory from OS_Get_Locale should be free according to its doc
  • Loading branch information
zsx committed Feb 25, 2014
1 parent 3cdf63b commit 253c64b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/b-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,21 +822,25 @@ static REBCNT Set_Option_Word(REBCHR *str, REBCNT field)
if (NZ(data = OS_GET_LOCALE(0))) {
val = Get_System(SYS_LOCALE, LOCALE_LANGUAGE);
Set_String(val, Copy_OS_Str(data, LEN_STR(data)));
OS_FREE(data);
}

if (NZ(data = OS_GET_LOCALE(1))) {
val = Get_System(SYS_LOCALE, LOCALE_LANGUAGE_P);
Set_String(val, Copy_OS_Str(data, LEN_STR(data)));
OS_FREE(data);
}

if (NZ(data = OS_GET_LOCALE(2))) {
val = Get_System(SYS_LOCALE, LOCALE_LOCALE);
Set_String(val, Copy_OS_Str(data, LEN_STR(data)));
OS_FREE(data);
}

if (NZ(data = OS_GET_LOCALE(3))) {
val = Get_System(SYS_LOCALE, LOCALE_LOCALE_P);
Set_String(val, Copy_OS_Str(data, LEN_STR(data)));
OS_FREE(data);
}
}

Expand Down

0 comments on commit 253c64b

Please sign in to comment.