locale.c: Avoid a leak
authorKarl Williamson <khw@cpan.org>
Fri, 4 Mar 2016 17:12:43 +0000 (10:12 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 4 Mar 2016 19:04:20 +0000 (12:04 -0700)
This reorders things to allow a free to be done.  The cause was spotted
by Tony Cook.

locale.c

index 0a2669f..20e5e98 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -190,13 +190,17 @@ Perl_new_numeric(pTHX_ const char *newnum)
     }
 
     save_newnum = stdize_locale(savepv(newnum));
+
+    PL_numeric_standard = isNAME_C_OR_POSIX(save_newnum);
+    PL_numeric_local = TRUE;
+
     if (! PL_numeric_name || strNE(PL_numeric_name, save_newnum)) {
        Safefree(PL_numeric_name);
        PL_numeric_name = save_newnum;
     }
-
-    PL_numeric_standard = isNAME_C_OR_POSIX(save_newnum);
-    PL_numeric_local = TRUE;
+    else {
+       Safefree(save_newnum);
+    }
 
     /* Keep LC_NUMERIC in the C locale.  This is for XS modules, so they don't
      * have to worry about the radix being a non-dot.  (Core operations that