summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2021-09-12 10:39:53 +0100
committerKarl Williamson <khw@cpan.org>2021-09-12 17:19:58 -0600
commite0f95237e410dc356b393fde2beec8ec83d476ef (patch)
tree9160952527f42ea0bb2aafeac05a100a4a2155bf /locale.c
parent00164771421225a404b0f24a96ce9a65e76b4215 (diff)
downloadperl-e0f95237e410dc356b393fde2beec8ec83d476ef.tar.gz
Check for NULL locale in S_emulate_setlocale
gcc-11.2.0 correctly warns that it is called with NULL from Perl_switch_to_global_locale().
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/locale.c b/locale.c
index 102fd970a0..c83076da3f 100644
--- a/locale.c
+++ b/locale.c
@@ -553,12 +553,13 @@ S_emulate_setlocale(const int category,
int mask;
locale_t old_obj;
locale_t new_obj;
+ const char * safelocale = locale ? locale : "(null)";
dTHX;
# ifdef DEBUGGING
if (DEBUG_Lv_TEST || debug_initialization) {
- PerlIO_printf(Perl_debug_log, "%s:%d: emulate_setlocale input=%d (%s), \"%s\", %d, %d\n", __FILE__, __LINE__, category, category_name(category), locale, index, is_index_valid);
+ PerlIO_printf(Perl_debug_log, "%s:%d: emulate_setlocale input=%d (%s), \"%s\", %d, %d\n", __FILE__, __LINE__, category, category_name(category), safelocale, index, is_index_valid);
}
# endif
@@ -586,7 +587,7 @@ S_emulate_setlocale(const int category,
* Fallback to the early POSIX usages */
Perl_warner(aTHX_ packWARN(WARN_LOCALE),
"Unknown locale category %d; can't set it to %s\n",
- category, locale);
+ category, safelocale);
return NULL;
found_index: ;