This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Save needed value before destroying it
authorKarl Williamson <khw@cpan.org>
Sat, 24 Feb 2018 23:32:44 +0000 (16:32 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 25 Feb 2018 16:48:27 +0000 (09:48 -0700)
This moves up the copying of a needed value to before the place where it
could get destroyed.  This only happened on some configurations under
some circumstances, which is why it got missed.

locale.c

index 9052fcc..2b1701f 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -2131,7 +2131,8 @@ Perl_setlocale(const int category, const char * locale)
 
 #endif
 
-    retval = do_setlocale_r(category, locale);
+    retval = save_to_buffer(do_setlocale_r(category, locale),
+                            &PL_setlocale_buf, &PL_setlocale_bufsize, 0);
     SAVE_ERRNO;
 
 #if defined(USE_LOCALE_NUMERIC) && defined(LC_ALL)
@@ -2152,8 +2153,6 @@ Perl_setlocale(const int category, const char * locale)
         return NULL;
     }
 
-    retval = save_to_buffer(retval, &PL_setlocale_buf, &PL_setlocale_bufsize, 0);
-
     /* If locale == NULL, we are just querying the state */
     if (locale == NULL) {
         return retval;