This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
use SvCUR(PL_numeric_radix_sv) not SvLEN()
authorDavid Mitchell <davem@iabyn.com>
Mon, 15 May 2017 10:59:49 +0000 (11:59 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:01 +0000 (09:11 +0100)
When determining the length of buffer needed to output the decimal point
in the current locale, use SvCUR(PL_numeric_radix_sv) rather than
SvLEN(PL_numeric_radix_sv). I presume this was a thinko in the original
commit. Using SvLEN currently seems harmless, since typically SvCUR <
SvLEN, but one could conceive a future scenario where locale info is set
using alien string buffers with SvLEN(sv) == 0.

sv.c

diff --git a/sv.c b/sv.c
index 27ca2ee..1c4f276 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3147,8 +3147,8 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
                     STORE_LC_NUMERIC_SET_TO_NEEDED();
 
                     local_radix = PL_numeric_local && PL_numeric_radix_sv;
-                    if (local_radix && SvLEN(PL_numeric_radix_sv) > 1) {
-                        size += SvLEN(PL_numeric_radix_sv) - 1;
+                    if (local_radix && SvCUR(PL_numeric_radix_sv) > 1) {
+                        size += SvCUR(PL_numeric_radix_sv) - 1;
                         s = SvGROW_mutable(sv, size);
                     }
 
@@ -12455,7 +12455,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 #ifdef USE_LOCALE_NUMERIC
                         STORE_LC_NUMERIC_SET_TO_NEEDED();
                         if (PL_numeric_radix_sv && IN_LC(LC_NUMERIC))
-                            float_need += SvLEN(PL_numeric_radix_sv);
+                            float_need += SvCUR(PL_numeric_radix_sv);
                         RESTORE_LC_NUMERIC();
 #endif
                 }