This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Check return code
authorKarl Williamson <khw@cpan.org>
Sun, 4 Mar 2018 02:17:43 +0000 (19:17 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 4 Mar 2018 02:55:58 +0000 (19:55 -0700)
In cases like these, we should give up if the called function fails.

locale.c

index 9970ae6..b53cb37 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -869,7 +869,11 @@ S_emulate_setlocale(const int category,
                                                 && strNE(env_override, ""))
                                                ? env_override
                                                : default_name;
-                    emulate_setlocale(categories[i], this_locale, i, TRUE);
+                    if (! emulate_setlocale(categories[i], this_locale, i, TRUE))
+                    {
+                        Safefree(env_override);
+                        return NULL;
+                    }
 
                     if (strNE(this_locale, default_name)) {
                         did_override = TRUE;
@@ -964,7 +968,10 @@ S_emulate_setlocale(const int category,
 
                 assert(category == LC_ALL);
                 individ_locale = Perl_form(aTHX_ "%.*s", (int) (p - s), s);
-                emulate_setlocale(categories[i], individ_locale, i, TRUE);
+                if (! emulate_setlocale(categories[i], individ_locale, i, TRUE))
+                {
+                    return NULL;
+                }
             }
 
             s = p;