aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libctf/ChangeLog5
-rw-r--r--libctf/ctf-decl.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 288ad6e..d840bc4 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,10 @@
2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+ * ctf-decl.c (ctf_decl_fini): Free the cd_buf.
+ (ctf_decl_buf): Once it escapes, don't try to free it later.
+
+2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+
* ctf-types.c (ctf_type_aname): Print arg types here...
* ctf-dump.c (ctf_dump_funcs): ... not here: but do substitute
in the type name here.
diff --git a/libctf/ctf-decl.c b/libctf/ctf-decl.c
index 5dcf60a..faf421e 100644
--- a/libctf/ctf-decl.c
+++ b/libctf/ctf-decl.c
@@ -68,6 +68,7 @@ ctf_decl_fini (ctf_decl_t *cd)
free (cdp);
}
}
+ free (cd->cd_buf);
}
void
@@ -195,5 +196,7 @@ void ctf_decl_sprintf (ctf_decl_t *cd, const char *format, ...)
char *ctf_decl_buf (ctf_decl_t *cd)
{
- return cd->cd_buf;
+ char *buf = cd->cd_buf;
+ cd->cd_buf = NULL;
+ return buf;
}