String with NULL auto-increment bug fix
authorBo Borgerson <gigabo@gmail.com>
Sun, 16 Aug 2009 15:07:39 +0000 (11:07 -0400)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 25 Aug 2009 08:22:58 +0000 (10:22 +0200)
Check position relative to end of string length rather than whether
char is NULL at end of initial alphanumerics in Perl_sv_inc

sv.c
t/op/auto.t

diff --git a/sv.c b/sv.c
index b9f682c..a53669a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -7298,7 +7298,7 @@ Perl_sv_inc(pTHX_ register SV *const sv)
     d = SvPVX(sv);
     while (isALPHA(*d)) d++;
     while (isDIGIT(*d)) d++;
-    if (*d) {
+    if (d < SvEND(sv)) {
 #ifdef PERL_PRESERVE_IVUV
        /* Got to punt this as an integer if needs be, but we don't issue
           warnings. Probably ought to make the sv_iv_please() that does
index 6dcc201..ecfe48b 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
 }
 
 require "test.pl";
-plan( tests => 37 );
+plan( tests => 39 );
 
 $x = 10000;
 cmp_ok(0 + ++$x - 1,'==',10000,'scalar ++x - 1');
@@ -47,6 +47,8 @@ cmp_ok($x{0},          '==',10000,'helem x final');
 # test magical autoincrement
 
 cmp_ok(++($foo = '99'), 'eq','100','99 incr 100');
+cmp_ok(++($foo = "99a"), 'eq','100','99a incr 100');
+cmp_ok(++($foo = "99\0a"), 'eq','100','99\0a incr 100');
 cmp_ok(++($foo = 'a0'), 'eq','a1','a0 incr a1');
 cmp_ok(++($foo = 'Az'), 'eq','Ba','Az incr Ba');
 cmp_ok(++($foo = 'zz'), 'eq','aaa','zzz incr aaa');