[pango/matthiasc/for-master] tests: Avoid a possible invalid access
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/matthiasc/for-master] tests: Avoid a possible invalid access
- Date: Sat, 10 Jul 2021 22:06:18 +0000 (UTC)
commit e8ff5bf30d3618be65520ee0f14beed71486157c
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 10 17:14:39 2021 -0400
tests: Avoid a possible invalid access
The return value of setlocale is only good until
the next call.
tests/meson.build | 1 +
tests/test-layout.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index baf5ad6b..841a78eb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -16,6 +16,7 @@ test_env = environment()
test_env.set('srcdir', meson.current_source_dir())
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+test_env.set('LC_ALL', 'en_US.UTF-8')
tests = [
[ 'test-bidi' ],
diff --git a/tests/test-layout.c b/tests/test-layout.c
index ca9e5da5..78e98b76 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -703,7 +703,7 @@ test_layout (gconstpointer d)
GString *dump;
gchar *diff;
- const char *old_locale = setlocale (LC_ALL, NULL);
+ char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
setlocale (LC_ALL, "en_US.utf8");
if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
{
@@ -726,6 +726,7 @@ test_layout (gconstpointer d)
g_assert_no_error (error);
setlocale (LC_ALL, old_locale);
+ g_free (old_locale);
if (diff && diff[0])
{
@@ -755,6 +756,8 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
+ setlocale (LC_ALL, "");
+
if (g_getenv ("PANGO_TEST_SHOW_FONT"))
opt_show_font = TRUE;
@@ -763,8 +766,6 @@ main (int argc, char *argv[])
{
GString *string;
- setlocale (LC_ALL, "en_US.utf8");
-
string = g_string_sized_new (0);
test_file (argv[1], string);
g_print ("%s", string->str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]