This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RT #96354: \h \H \v and \V didn't check for EOL
authorDavid Mitchell <davem@iabyn.com>
Fri, 5 Aug 2011 16:46:46 +0000 (17:46 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 5 Aug 2011 16:49:51 +0000 (17:49 +0100)
The HORIZWS and similar regexp ops didn't check that the end of the string
had been reached; therefore they would blithely compare against the \0 at
the end of the string, or beyond.

regexec.c
t/re/re_tests

index 76c91af..bdd5e3f 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -5683,6 +5683,8 @@ NULL
 
 #define CASE_CLASS(nAmE)                              \
         case nAmE:                                    \
+           if (locinput >= PL_regeol)                \
+               sayNO;                                \
             if ((n=is_##nAmE(locinput,utf8_target))) {    \
                 locinput += n;                        \
                 nextchr = UCHARAT(locinput);          \
@@ -5690,6 +5692,8 @@ NULL
                 sayNO;                                \
             break;                                    \
         case N##nAmE:                                 \
+           if (locinput >= PL_regeol)                \
+               sayNO;                                \
             if ((n=is_##nAmE(locinput,utf8_target))) {    \
                 sayNO;                                \
             } else {                                  \
index 35a7220..978e02c 100644 (file)
@@ -1,7 +1,10 @@
 # This stops me getting screenfulls of syntax errors every time I accidentally
-# run this file via a shell glob.  Format of this file is given in regexp.t
+# run this file via a shell glob.  The full format of this file is given
+# in regexp.t
 # Can't use \N{VALID NAME TEST} here because need 'use charnames'; but can use
 # \N{U+valid} here.
+#
+# pat  string  y/n/etc expr    expected-expr   skip-reason
 __END__
 abc    abc     y       $&      abc
 abc    abc     y       $-[0]   0
@@ -1522,4 +1525,9 @@ abc\N{def -       c       -       \\N{NAME} must be resolved by the lexer
 # See [perl #89750].  This makes sure that the simple fold gets generated
 # in that case, to DF.
 /[^\x{1E9E}]/i \x{DF}  n       -       -
+
+# RT #96354
+/^.*\d\H/      X1      n       -       -
+/^.*\d\V/      X1      n       -       -
+
 # vim: softtabstop=0 noexpandtab