[PATCH 05/34] Arm: use is_end_of_stmt()

Jan Beulich jbeulich@suse.com
Thu Feb 20 12:56:11 GMT 2025


On 20.02.2025 10:14, Nick Clifton wrote:
>> ... instead of open-coding it. This also fixes an array underrun issue:
>> The wrong casting to plain int could have yielded negative values when
>> plain char is a signed type.
>>
>> --- a/gas/config/tc-arm.c
>> +++ b/gas/config/tc-arm.c
>> @@ -3668,7 +3668,7 @@ tc_start_label_without_colon (void)
>>       {
>>         const char *label = input_line_pointer;
>>   
>> -      while (!is_end_of_line[(int) label[-1]])
>> +      while (!is_end_of_stmt (label[-1]))
>  >   	--label;
> 
> Sure that makes sense to be.  I am worries about this potentially
> unbounded backwards scan, but I cannot think of a reasonable way
> of preventing it short of reworking the whole input_line_pointer
> mechanism.

At the time of putting the patch together, I had already written a remark
regarding this backward scan, but upon re-checking I found that input
reading logic guarantees a \n to be immediately ahead of the first byte
of the current chunk of input we process. Apparently to permit such
ugliness ...

Jan


More information about the Binutils mailing list