[PATCH 2/3] RISC-V: Free the returned string of riscv_arch_str if we call it multiple times

Nelson Chu nelson@rivosinc.com
Tue Mar 18 04:24:22 GMT 2025


Committed after applying the changes of comment.

Thanks
Nelson

On Fri, Mar 14, 2025 at 12:49 AM Nelson Chu <nelson@rivosinc.com> wrote:

> Thanks!  These are helpful ;)
>
> Nelson
>
> On Thu, Mar 13, 2025 at 3:45 PM Jan Beulich <jbeulich@suse.com> wrote:
>
>> On 13.03.2025 03:31, Nelson Chu wrote:
>> > @@ -4001,6 +4001,10 @@ riscv_merge_arch_attr_info (bfd *ibfd, char
>> *in_arch, char *out_arch)
>> >        return NULL;
>> >      }
>> >
>> > +  /* Free the previous merged_arch_str which called xmalloc.  */
>> > +  if (merged_arch_str != NULL)
>> > +    free ((void *) merged_arch_str);
>>
>> Nit: There's no need for the cast in modern C, and there's also no need
>> for the
>> NULL check, as free() deals with NULL just fine.
>>
>> Jan
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20250318/0cfbf42e/attachment.htm>


More information about the Binutils mailing list