[PATCH 2/3] RISC-V: Free the returned string of riscv_arch_str if we call it multiple times
Nelson Chu
nelson@rivosinc.com
Thu Mar 13 16:49:29 GMT 2025
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/20250314/2a200b41/attachment.htm>
More information about the Binutils
mailing list