From: Bo Borgerson Date: Sun, 16 Aug 2009 15:07:39 +0000 (-0400) Subject: String with NULL auto-increment bug fix X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6aff239d5283e5d4ba7b451221311e53b9690309;p=p5sagit%2Fp5-mst-13.2.git String with NULL auto-increment bug fix Check position relative to end of string length rather than whether char is NULL at end of initial alphanumerics in Perl_sv_inc --- diff --git a/sv.c b/sv.c index b9f682c..a53669a 100644 --- 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 diff --git a/t/op/auto.t b/t/op/auto.t index 6dcc201..ecfe48b 100644 --- a/t/op/auto.t +++ b/t/op/auto.t @@ -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');