gas s_comm_internal uninitialised access

Alan Modra amodra@gmail.com
Sat Jun 6 01:22:06 GMT 2026


After elf_common_parse calls ignore_rest_of_line on some errors,
s_comm_internal calls demand_empty_rest_of_line.  These functions
cannot be both called, as they consume the end_of_stmt char in the
input buffer and the second call then consumes the next line of input,
which may not even be in the input buffer.

	* config/obj-elf.c (elf_common_parse): Don't call
	ignore_rest_of_line here.
	* read.c (ignore_rest_of_line): Expand comment.

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 7b120ff8eeb..09a224147e9 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -275,7 +275,6 @@ elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP, addressT size)
 	      *input_line_pointer = '\0';
 	      as_bad (_("bad .common segment %s"), p);
 	      *input_line_pointer = c;
-	      ignore_rest_of_line ();
 	      return NULL;
 	    }
 	  /* ??? Don't ask me why these are always global.  */
diff --git a/gas/read.c b/gas/read.c
index 7a0c73abc5c..5b6a3c115a0 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -4101,8 +4101,10 @@ demand_empty_rest_of_line (void)
 /* Silently advance to the end of a statement.  Use this after already having
    issued an error about something bad.  Like demand_empty_rest_of_line,
    this function may leave input_line_pointer one after buffer_limit;
-   Don't call it from within expression parsing code in an attempt to
-   silence further errors.  */
+   Don't call it twice, and don't call both ignore_rest_of_line and
+   demand_empty_rest_of_line as that will consume two lines of input.
+   This rule leads to:  Don't call it from within expression parsing
+   code in an attempt to silence further errors.  */
 
 void
 ignore_rest_of_line (void)

-- 
Alan Modra


More information about the Binutils mailing list