summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2018-06-27 09:54:06 +0100
committerPhilip Withnall <withnall@endlessm.com>2018-06-29 12:13:32 +0100
commit68526565f41383f2c588951bf7e4de7a7ea4c162 (patch)
tree25ca5ca7733d73b101ad6e6a2ced9909070a1940 /gio
parent61da8748fdfb1a86b3a0493bbc0dd03ff17dcb22 (diff)
downloadglib-68526565f41383f2c588951bf7e4de7a7ea4c162.tar.gz
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>
Diffstat (limited to 'gio')
-rw-r--r--gio/tests/appinfo.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c
index 2e69da051..d9d61b605 100644
--- a/gio/tests/appinfo.c
+++ b/gio/tests/appinfo.c
@@ -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