This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Catch unbalanced curly parentheses in read_braced_string()


Hi Guys,

  Whilst editing a .md file I accidentally added one too many opening
  curly braces.  This caused genconstants to go into an infinite loop
  because read_braced_string() never checks for end-of-file.

  The following patch fixes this problem and causes the program to
  issue an error message describing where the original opening curly
  braces was located.

  May I apply this patch please ?

Cheers
        Nick

2003-06-23  Nick Clifton  <nickc@redhat.com>

	* read-rtl.c (read_braced_string): Check for EOF.  If
	encountered issue an error message.

Index: gcc/read-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/read-rtl.c,v
retrieving revision 1.18
diff -c -3 -p -r1.18 read-rtl.c
*** gcc/read-rtl.c	16 Jun 2003 21:41:06 -0000	1.18
--- gcc/read-rtl.c	23 Jun 2003 07:28:33 -0000
*************** read_braced_string (ob, infile)
*** 298,308 ****
--- 298,315 ----
  {
    int c;
    int brace_depth = 1;  /* caller-processed */
+   unsigned long starting_read_rtx_lineno = read_rtx_lineno;
  
    obstack_1grow (ob, '{');
    while (brace_depth)
      {
        c = getc (infile); /* Read the string  */
+ 
+       if (c == EOF)
+ 	fatal_with_file_and_line
+ 	  (infile, "missing closing } for opening brace on line %lu",
+ 	   starting_read_rtx_lineno);
+       
        if (c == '\n')
  	read_rtx_lineno++;
        else if (c == '{')


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]