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]

Fix PR gas/7020, uninitialized read


AFAICT, on inspection, nothing bad could come out of the bug
except perhaps for a SEGV if there's a '=' before EOF and it was
right at the end of a page in the input buffer and bad luck.

The new arrangement seems a tiny bit more readable, even though
I copied the conditional to both the main "||" arms.  Fixes the
problem; valgrind doesn't complain anymore.  This is intended to
be logically equivalent except evaluating input_line_pointer[*]
in monotonically increasing order.

Ok to commit?

	* read.c (read_a_source_file): Rearrange evaluation order when
	looking for '=' to avoid conditional on undefined contents of
	input_line_pointer[1].

Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.142
diff -p -u -r1.142 read.c
--- read.c	7 Oct 2008 14:21:59 -0000	1.142
+++ read.c	11 Nov 2008 16:45:17 -0000
@@ -791,10 +791,10 @@ read_a_source_file (char *name)
 		  /* Input_line_pointer->after ':'.  */
 		  SKIP_WHITESPACE ();
 		}
-              else if (input_line_pointer[1] == '='
-		       && (c == '='
-			   || ((c == ' ' || c == '\t')
-			       && input_line_pointer[2] == '=')))
+              else if ((c == '=' && input_line_pointer[1] == '=')
+		       || ((c == ' ' || c == '\t')
+			   && input_line_pointer[1] == '='
+			   && input_line_pointer[2] == '='))
 		{
 		  equals (s, -1);
 		  demand_empty_rest_of_line ();

brgds, H-P


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