Put a check for capture index.

* genmatch.c (parse_capture): Add condition to check capture index.
                     (capture_max): New constant.
                     (stdlib.h): Include.

Thanks and Regards,
Prathamesh
Index: genmatch.c
===================================================================
--- genmatch.c	(revision 211732)
+++ genmatch.c	(working copy)
@@ -29,7 +29,9 @@ along with GCC; see the file COPYING3.
 #include "hashtab.h"
 #include "hash-table.h"
 #include "vec.h"
+#include <stdlib.h>
 
+const unsigned capture_max = 4;
 
 /* libccp helpers.  */
 
@@ -816,7 +818,11 @@ static struct operand *
 parse_capture (cpp_reader *r, operand *op)
 {
   eat_token (r, CPP_ATSIGN);
-  return new capture (get_number (r), op);
+  const cpp_token *token = peek (r);
+  const char *num = get_number (r);
+  if (atoi (num) >= capture_max)
+    fatal_at (token, "capture cannot be greater than %u", capture_max - 1);
+  return new capture (num, op);
 }
 
 /* Parse

Reply via email to