Skip to content

Commit

Permalink
msvcrt: Reference old locinfo for create_locinfo().
Browse files Browse the repository at this point in the history
CW-Bug-Id: #23214
  • Loading branch information
Paul Gofman committed Jan 9, 2024
1 parent a9ece6e commit 6252c53
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dlls/msvcrt/locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ char* CDECL setlocale(int category, const char* locale)
{
thread_data_t *data = msvcrt_get_thread_data();
pthreadlocinfo locinfo = get_locinfo(), newlocinfo;
BOOL need_free;

if(category<LC_MIN || category>LC_MAX)
return NULL;
Expand All @@ -2047,7 +2048,12 @@ char* CDECL setlocale(int category, const char* locale)
return locinfo->lc_category[category].locale;
}

if ((need_free = (locinfo && data->locale_flags & LOCALE_FREE)))
grab_locinfo(locinfo);
newlocinfo = create_locinfo(category, locale, locinfo);
if (need_free)
free_locinfo(locinfo);

if(!newlocinfo) {
WARN("%d %s failed\n", category, locale);
return NULL;
Expand Down

0 comments on commit 6252c53

Please sign in to comment.