summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-07-03 14:26:13 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-07-03 14:26:13 +0000
commitead4c2def6106b143846c6de0179fa3e6af2845f (patch)
tree4fd9f5b32507e8ddf028475890616c988cbd4050
parentb3affbb58a452a300f9da5f19ca962168d4c66d4 (diff)
downloadperl-ead4c2def6106b143846c6de0179fa3e6af2845f.tar.gz
Forbid \g0. (tests coming later)
p4raw-id: //depot/perl@31524
-rw-r--r--pod/perldiag.pod7
-rw-r--r--regcomp.c2
2 files changed, 9 insertions, 0 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index d0cedfc28a..338fd12da6 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -3556,6 +3556,13 @@ Doing so has no effect.
(W internal) The internal sv_replace() function was handed a new SV with
a reference count of other than 1.
+=item Reference to invalid group 0
+
+(F) You used C<\g0> or similar in a regular expression. You may refer to
+capturing parentheses only with strictly positive integers (normal
+backreferences) or with stricly negative integers (relative
+backreferences), but using 0 does not make sense.
+
=item Reference to nonexistent group in regex; marked by <-- HERE in m/%s/
(F) You used something like C<\7> in your regular expression, but there are
diff --git a/regcomp.c b/regcomp.c
index 60b31ed23b..cada4cdd26 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -7052,6 +7052,8 @@ tryagain:
goto parse_named_seq;
} }
num = atoi(RExC_parse);
+ if (isg && num == 0)
+ vFAIL("Reference to invalid group 0");
if (isrel) {
num = RExC_npar - num;
if (num < 1)