ctf_decl_sprintf builds up a formatted string in the ctf_decl_t's
cd_buf, but then on error this is hardly ever freed: we assume that
ctf_decl_fini frees it, but it leaks it instead.
Make it free it like any decent ADT should.
libctf/
* 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-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...
free (cdp);
}
}
+ free (cd->cd_buf);
}
void
char *ctf_decl_buf (ctf_decl_t *cd)
{
- return cd->cd_buf;
+ char *buf = cd->cd_buf;
+ cd->cd_buf = NULL;
+ return buf;
}