summaryrefslogtreecommitdiff
path: root/t/loc_tools.pl
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-04-12 05:08:10 -0600
committerKarl Williamson <khw@cpan.org>2022-08-18 07:57:30 -0600
commiteb1c747cc5e636336d4c6f2c9abd88dd91269b59 (patch)
tree65c986f36b41bad1d15ba1c549b12927c5e2b4a3 /t/loc_tools.pl
parent63eccc74b3f1a706b7a219f15f42dd6650b20c4b (diff)
downloadperl-eb1c747cc5e636336d4c6f2c9abd88dd91269b59.tar.gz
t/loc_tools.pl: Add checks
This verifies that we can restore a locale that we were previously in, and makes sure that we don't stay in a locale that doesn't work well. Doing so has led to crashes.
Diffstat (limited to 't/loc_tools.pl')
-rw-r--r--t/loc_tools.pl8
1 files changed, 7 insertions, 1 deletions
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index 0b6962dbf4..8707fedcad 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -191,6 +191,10 @@ sub _trylocale ($$$$) { # For use only by other functions in this file!
no locale;
+ # We definitely don't want the locale set to something that is
+ # unsupported
+ die "Couldn't restore locale '$save_locale', category $category"
+ unless setlocale($category, $save_locale);
if ($badutf8) {
_my_fail("Verify locale name doesn't contain malformed utf8");
return;
@@ -646,7 +650,9 @@ sub find_utf8_turkic_locales (;$) {
setlocale(&POSIX::LC_CTYPE(), $locale);
push @return, $locale if uc('i') eq "\x{130}";
}
- setlocale(&POSIX::LC_CTYPE(), $save_locale);
+
+ die "Couldn't restore locale '$save_locale'"
+ unless setlocale(&POSIX::LC_CTYPE(), $save_locale);
return @return;
}