This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove gdb_bfd_stash_filename to fix crash with fix of binutils/11983


>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> gdb has been confused and went in circles, with bfd's filename
Pedro> ownership.  In some places, it ended up xmalloc/xstrdup'ing the
Pedro> filename instead of allocating it in the bfd's memory.
Pedro> That resulted in the invention of gdb_bfd_stash_filename
Pedro> https://sourceware.org/ml/gdb-patches/2012-07/msg00291.html
Pedro> as a workaround.

Yeah, in retrospect I should have tried to fix up BFD at that time.

Pedro> I think it'd be better to allocate the filename
Pedro> in the bfd's memory, like it used to be.

I agree.  I think your patch is better due to keeping the same
error-handling approach as the rest of BFD.

Pedro> WDYT?

If you don't mind I think it would be good -- and easy -- to also
implement Doug's suggestion, say a "bfd_set_filename" macro.

Pedro> +/* A wrapper for bfd_strdup that never returns NULL.  */
Pedro> +
Pedro> +char *gdb_bfd_strdup (bfd *abfd, const char *str);

This can be marked ATTRIBUTE_RETURNS_NONNULL.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]