]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas s_comm_internal uninitialised access
authorAlan Modra <amodra@gmail.com>
Sat, 6 Jun 2026 01:35:45 +0000 (11:05 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 6 Jun 2026 01:35:45 +0000 (11:05 +0930)
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.

gas/config/obj-elf.c
gas/read.c

index 7b120ff8eeb3de5b040a528d55c8bcb629b8c7e0..09a224147e93139de357122f20a2fd814d1a96f4 100644 (file)
@@ -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.  */
index 7a0c73abc5c2a341c2da1f4ecb8c24a2b39399ca..5b6a3c115a0220c2b4b90d09e2be3da22c460748 100644 (file)
@@ -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)