From b03f34cfd0bd2bbf204c9c669cd107351c03e4e3 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 27 Jun 2013 14:25:43 -0600 Subject: [PATCH] locale.c: Compare apples to apples Prior to this patch, one parameter to strNE would have been through a standardizing function, while the other had not. By standardizing both before doing the compare, we avoid false positives. --- locale.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/locale.c b/locale.c index bb0baf5..a73a864 100644 --- a/locale.c +++ b/locale.c @@ -111,6 +111,7 @@ void Perl_new_numeric(pTHX_ const char *newnum) { #ifdef USE_LOCALE_NUMERIC + char *save_newnum; dVAR; if (! newnum) { @@ -121,14 +122,18 @@ Perl_new_numeric(pTHX_ const char *newnum) return; } - if (! PL_numeric_name || strNE(PL_numeric_name, newnum)) { + save_newnum = stdize_locale(savepv(newnum)); + if (! PL_numeric_name || strNE(PL_numeric_name, save_newnum)) { Safefree(PL_numeric_name); - PL_numeric_name = stdize_locale(savepv(newnum)); - PL_numeric_standard = ((*newnum == 'C' && newnum[1] == '\0') - || strEQ(newnum, "POSIX")); + PL_numeric_name = save_newnum; + PL_numeric_standard = ((*save_newnum == 'C' && save_newnum[1] == '\0') + || strEQ(save_newnum, "POSIX")); PL_numeric_local = TRUE; set_numeric_radix(); } + else { + Safefree(save_newnum); + } #endif /* USE_LOCALE_NUMERIC */ } -- 1.8.3.1