On 6/18/19 11:56 AM, Martin Liška wrote:
> On 6/18/19 10:23 AM, Martin Liška wrote:
>> On 6/18/19 10:11 AM, Jakub Jelinek wrote:
>>> On Tue, Jun 18, 2019 at 10:07:50AM +0200, Martin Liška wrote:
>>>> diff --git a/gcc/builtins.c b/gcc/builtins.c
>>>> index 3463ffb1539..b58e1e58d4d 100644
>>>> --- a/gcc/builtins.c
>>>> +++ b/gcc/builtins.c
>>>> @@ -7142,6 +7142,20 @@ inline_expand_builtin_string_cmp (tree exp, rtx 
>>>> target)
>>>>    const char *src_str1 = c_getstr (arg1, &len1);
>>>>    const char *src_str2 = c_getstr (arg2, &len2);
>>>>  
>>>> +  if (src_str1 != NULL)
>>>> +    {
>>>> +      unsigned HOST_WIDE_INT str_str1_strlen = strnlen (src_str1, len1);
>>>> +      if (str_str1_strlen + 1 < len1)
>>>> +  len1 = str_str1_strlen + 1;
>>>
>>> You really don't need any of this after strnlen.  strnlen is already
>>> guaranteed to return a number from 0 to len1 inclusive, so you can really
>>> just do:
>>>   if (src_str1 != NULL)
>>>     len1 = strnlen (src_str1, len1);
>>>
>>>     Jakub
>>>
>>
>> Got it, I'm testing that.
>>
>> Martin
>>
> 
> Ok, there's an off-by-one error in the previous patch candidate.
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?
> Thanks,
> Martin
> 

Patch to this. I hope this version of the patch is correct.
Jakub?

Thanks,
Martin

Reply via email to