mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-16 06:08:09 +08:00
libctf: dump: fix small leak
If you asprintf something and then use it only as input to another asprintf, it helps to free it afterwards. libctf/ * ctf-dump.c (ctf_dump_header): Free the flagstr after use. (ctf_dump): Make a NULL return slightly clearer.
This commit is contained in:
@@ -349,6 +349,7 @@ ctf_dump_header (ctf_dict_t *fp, ctf_dump_state_t *state)
|
|||||||
|
|
||||||
if (asprintf (&str, "Flags: 0x%x (%s)", fp->ctf_openflags, flagstr) < 0)
|
if (asprintf (&str, "Flags: 0x%x (%s)", fp->ctf_openflags, flagstr) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
free (flagstr);
|
||||||
ctf_dump_append (state, str);
|
ctf_dump_append (state, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,7 +815,7 @@ ctf_dump (ctf_dict_t *fp, ctf_dump_state_t **statep, ctf_sect_names_t sect,
|
|||||||
if (!str)
|
if (!str)
|
||||||
{
|
{
|
||||||
ctf_set_errno (fp, ENOMEM);
|
ctf_set_errno (fp, ENOMEM);
|
||||||
return str;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user