mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Fix heap use-after-free with setlocale
In glibc the return value of setlocale() is allocated in static storage, which may be invalidated by subsequent calls.
This commit is contained in:
parent
d1a3c0eaa3
commit
d467a79fdb
@ -1069,7 +1069,7 @@ int fscanf_no_i18n(FILE *stream, const char *format, ...) {
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
#ifdef BUILD_I18N
|
#ifdef BUILD_I18N
|
||||||
const char *oldlocale = setlocale(LC_NUMERIC, nullptr);
|
char *oldlocale = strdup(setlocale(LC_NUMERIC, nullptr));
|
||||||
|
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
#endif
|
#endif
|
||||||
@ -1078,6 +1078,7 @@ int fscanf_no_i18n(FILE *stream, const char *format, ...) {
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
#ifdef BUILD_I18N
|
#ifdef BUILD_I18N
|
||||||
setlocale(LC_NUMERIC, oldlocale);
|
setlocale(LC_NUMERIC, oldlocale);
|
||||||
|
free(oldlocale);
|
||||||
#endif
|
#endif
|
||||||
return returncode;
|
return returncode;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user