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
[perl5.git] / 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;