util: check and initialize locale before using it

Cc: mesa-stable

Signed-off-by: Thong Thai <thong.thai@amd.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22699>
(cherry picked from commit 27eafdcbd5)
This commit is contained in:
Thong Thai 2023-04-25 16:12:53 -04:00 committed by Dylan Baker
parent 26e3bf39f7
commit 966bd8fb0b
2 changed files with 3 additions and 1 deletions

View file

@ -8674,7 +8674,7 @@
"description": "util: check and initialize locale before using it",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -69,6 +69,7 @@ double
_mesa_strtod(const char *s, char **end)
{
#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
if (!loc) _mesa_locale_init();
return strtod_l(s, end, loc);
#else
return strtod(s, end);
@ -84,6 +85,7 @@ float
_mesa_strtof(const char *s, char **end)
{
#if defined(_GNU_SOURCE) && defined(HAVE_STRTOD_L)
if (!loc) _mesa_locale_init();
return strtof_l(s, end, loc);
#elif defined(HAVE_STRTOF)
return strtof(s, end);