[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binutils
Subject:    [PATCH 3/3] gas: document that get_symbol_name() can clobber the input buffer
From:       Jan Beulich via Binutils <binutils () sourceware ! org>
Date:       2023-03-31 10:07:04
Message-ID: b9ae928e-7e33-e158-bc2e-5e832c2f6032 () suse ! com
[Download RAW message or body]

Callers which want to make further parsing attempts at the buffer passed
to the function need to be aware that due to the potential of string
concatenation the input buffer may be altered in ways beyond what can be
undone by putting back at *input_line_pointer the character that the
function returns.

--- a/gas/expr.c
+++ b/gas/expr.c
@@ -2388,12 +2388,17 @@ resolve_expression (expressionS *express
    here lessens the crowd at read.c.
 
    Assume input_line_pointer is at start of symbol name, or the
-    start of a double quote enclosed symbol name.
-   Advance input_line_pointer past symbol name.
-   Turn that character into a '\0', returning its former value,
-    which may be the closing double quote.
+   start of a double quote enclosed symbol name.  Advance
+   input_line_pointer past symbol name.  Turn that character into a '\0',
+   returning its former value, which may be the closing double quote.
+
    This allows a string compare (RMS wants symbol names to be strings)
-    of the symbol name.
+   of the symbol name.
+
+   NOTE: The input buffer is further altered when adjacent strings are
+   concatenated by the function.  Callers caring about the original buffer
+   contents will need to make a copy before calling here.
+
    There will always be a char following symbol name, because all good
    lines end in end-of-line.  */
 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic