From 1380b51d3b2bb6a067c4a2a3eebbe18650487023 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Fri, 5 Aug 2011 17:46:46 +0100 Subject: RT #96354: \h \H \v and \V didn't check for EOL 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 | 4 ++++ t/re/re_tests | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/regexec.c b/regexec.c index 76c91af1f7..bdd5e3faed 100644 --- 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 { \ diff --git a/t/re/re_tests b/t/re/re_tests index 35a72203cd..978e02c1dd 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -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 -- cgit v1.2.1