aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2024-07-29 18:02:03 +0100
committerNick Alcock <nick.alcock@oracle.com>2024-07-30 11:30:51 +0100
commitd56f5df657d41303b46f20fa80eae7ad3921b289 (patch)
tree5d4a7f71b4eb51fbaf87256ac7951bce7ee623e8
parent17708cd4cd6fca37e0417e3da4cc16d609882ba9 (diff)
downloadgdb-d56f5df657d41303b46f20fa80eae7ad3921b289.zip
gdb-d56f5df657d41303b46f20fa80eae7ad3921b289.tar.gz
gdb-d56f5df657d41303b46f20fa80eae7ad3921b289.tar.bz2
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.
-rw-r--r--libctf/ctf-dump.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index cd41996..a37d4b7 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -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)
goto err;
+ free (flagstr);
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)
{
ctf_set_errno (fp, ENOMEM);
- return str;
+ return NULL;
}
}