mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 20:44:56 +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;
|
||||
|
||||
#ifdef BUILD_I18N
|
||||
const char *oldlocale = setlocale(LC_NUMERIC, nullptr);
|
||||
char *oldlocale = strdup(setlocale(LC_NUMERIC, nullptr));
|
||||
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
#endif
|
||||
@ -1078,6 +1078,7 @@ int fscanf_no_i18n(FILE *stream, const char *format, ...) {
|
||||
va_end(ap);
|
||||
#ifdef BUILD_I18N
|
||||
setlocale(LC_NUMERIC, oldlocale);
|
||||
free(oldlocale);
|
||||
#endif
|
||||
return returncode;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user