mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
tests: Fix use-after-free in the appinfo tests
When changing the locale using setlocale(), duplicate the old locale value before updating it, so that we can safely restore the old locale after running the test. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
61da8748fd
commit
68526565f4
@ -128,10 +128,10 @@ static void
|
||||
test_locale (const char *locale)
|
||||
{
|
||||
GAppInfo *appinfo;
|
||||
const gchar *orig;
|
||||
gchar *orig = NULL;
|
||||
const gchar *path;
|
||||
|
||||
orig = setlocale (LC_ALL, NULL);
|
||||
orig = g_strdup (setlocale (LC_ALL, NULL));
|
||||
g_setenv ("LANGUAGE", locale, TRUE);
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
@ -161,6 +161,7 @@ test_locale (const char *locale)
|
||||
|
||||
g_setenv ("LANGUAGE", orig, TRUE);
|
||||
setlocale (LC_ALL, "");
|
||||
g_free (orig);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user