diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-02-06 18:11:48 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-02-06 18:12:13 -0800 |
commit | 54615b95ff238e235e806855efc46a9abad09f2e (patch) | |
tree | 19bee596fc7993d4fd97e42ec0be7e3ab0f566b9 /tests/test-localename.c | |
parent | e78f894d0bdc770101bc040613f4ea94e45f38f7 (diff) | |
download | gnulib-54615b95ff238e235e806855efc46a9abad09f2e.tar.gz |
misc: port better to gcc -fsanitize=address
Without these patches, ./configure CFLAGS='-fsanitize=address'
would compute incorrect values. This patch fixes some (but not all)
test failures with recent glibc, with this configuration.
* m4/acl.m4 (gl_ACL_GET_FILE):
* m4/calloc.m4 (_AC_FUNC_CALLOC_IF):
* m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS):
* m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO):
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE):
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL):
* m4/getdelim.m4 (gl_FUNC_GETDELIM):
* m4/getgroups.m4 (gl_FUNC_GETGROUPS):
* m4/getline.m4 (gl_FUNC_GETLINE):
* m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
* m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
* m4/regex.m4 (gl_REGEX):
* m4/strndup.m4 (gl_FUNC_STRNDUP):
* tests/test-calloc-gnu.c (main):
* tests/test-duplocale.c (main):
* tests/test-getgroups.c (main):
* tests/test-getline.c (main):
* tests/test-inttostr.c (main):
* tests/test-localename.c (test_locale_name)
(test_locale_name_thread, test_locale_name_environ)
(test_locale_name_default):
* tests/test-regex.c (main):
* tests/test-setlocale1.c (main):
* tests/test-stat.h (test_stat_func):
Free heap-allocated storage before exiting.
* m4/asm-underscore.m4 (gl_ASM_SYMBOL_PREFIX):
Don't match *_foo symbols inserted by AddressSanitizer.
* tests/test-regex.c, tests/test-stat.c: Include stdlib.h, for 'free'.
Diffstat (limited to 'tests/test-localename.c')
-rw-r--r-- | tests/test-localename.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/test-localename.c b/tests/test-localename.c index 040c025570..a61fa2cd9a 100644 --- a/tests/test-localename.c +++ b/tests/test-localename.c @@ -183,6 +183,8 @@ test_locale_name (void) ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); name = gl_locale_name (LC_MESSAGES, "LC_MESSAGES"); ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } } @@ -194,10 +196,10 @@ test_locale_name (void) for (i = 0; i < SIZEOF (categories); i++) { int category_mask = categories[i].mask; - locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); - if (locale != NULL) + locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (loc != NULL) { - locale = newlocale (category_mask, "de_DE.UTF-8", locale); + locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc); if (locale != NULL) { unsigned int j; @@ -212,7 +214,10 @@ test_locale_name (void) else ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0); } + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } + freelocale (loc); } } } @@ -245,6 +250,8 @@ test_locale_name_thread (void) ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); name = gl_locale_name_thread (LC_MESSAGES, "LC_MESSAGES"); ASSERT (strcmp (name, "fr_FR.UTF-8") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } } @@ -256,10 +263,10 @@ test_locale_name_thread (void) for (i = 0; i < SIZEOF (categories); i++) { int category_mask = categories[i].mask; - locale_t locale = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); - if (locale != NULL) + locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL); + if (loc != NULL) { - locale = newlocale (category_mask, "de_DE.UTF-8", locale); + locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc); if (locale != NULL) { unsigned int j; @@ -275,7 +282,10 @@ test_locale_name_thread (void) else ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0); } + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } + freelocale (loc); } } } @@ -444,6 +454,7 @@ test_locale_name_thread (void) ASSERT (strcmp (unsaved_names[j][i], name) == 0); } uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } } /* Verify the unsaved_names are still valid. */ @@ -590,6 +601,8 @@ test_locale_name_posix (void) uselocale (locale); name = gl_locale_name_posix (LC_MESSAGES, "LC_MESSAGES"); ASSERT (strcmp (name, "C") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } } #endif @@ -702,6 +715,8 @@ test_locale_name_environ (void) uselocale (locale); name = gl_locale_name_environ (LC_MESSAGES, "LC_MESSAGES"); ASSERT (strcmp (name, "C") == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } } #endif @@ -729,6 +744,8 @@ test_locale_name_default (void) { uselocale (locale); ASSERT (strcmp (gl_locale_name_default (), name) == 0); + uselocale (LC_GLOBAL_LOCALE); + freelocale (locale); } } #endif |