[PATCH,V3 1/3] CTF: fix incorrect function return type

Tom Tromey tom@tromey.com
Thu Apr 1 16:54:00 GMT 2021


>>>>> Weimin Pan via Gdb-patches <gdb-patches@sourceware.org> writes:

> +	Don't copy name returned from ctf_type_aname_raw throughout file.

To be clear, this relies on the pointers from libctf having the correct
lifetime.  If that's not the case, you'll get crashes.

> -  gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (fp, tid));
> +  char *name = ctf_type_aname_raw (fp, tid);

Dropping the unique_xmalloc_ptr here makes me suspect that
ctf_type_aname_raw is returning a malloc'd pointer.  So, this change
would seem to leak memory.

Tom


More information about the Gdb-patches mailing list