This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

PATCH: Allow UNGETC to work with an empty buffer


Hi Guys,

  I am checking in the patch below to fix a bug discovered by the
  current mainline gcc sources.  I was running a bootstrap build when
  it failed because it had worked out that one of the calls to the
  UNGETC macro in do_scrub_chars() would push a character into an
  empty buffer.  It was a very neat bit of analysis of a corner
  condition that had obviously been there for a long time.

Cheers
  Nick

gas/ChangeLog
2007-07-20  Nick Clifton  <nickc@redhat.com>

	* app.c (do_scrub_chars): Provide a one character buffer to hold a
	pushed back newline at the end of an unterminated quoted string.

Index: gas/app.c
===================================================================
RCS file: /cvs/src/src/gas/app.c,v
retrieving revision 1.43
diff -c -3 -p -r1.43 app.c
*** gas/app.c	3 Jul 2007 11:01:02 -0000	1.43
--- gas/app.c	20 Jul 2007 08:03:01 -0000
*************** do_scrub_chars (int (*get) (char *, int)
*** 558,565 ****
--- 558,571 ----
  	  ch = GET ();
  	  if (ch == EOF)
  	    {
+ 	      /* This buffer is here specifically so
+ 		 that the UNGET below will work.  */
+ 	      static char one_char_buf[1];
+ 
  	      as_warn (_("end of file in string; '%c' inserted"), quotechar);
  	      state = old_state;
+ 	      from = fromend = one_char_buf + 1;
+ 	      fromlen = 1;
  	      UNGET ('\n');
  	      PUT (quotechar);
  	    }


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