[DTrace-devel] [PATCH] Ensure record descriptors get cleaned up
Kris Van Hees
kris.van.hees at oracle.com
Fri Jun 19 00:48:59 PDT 2020
When a dtrace_datadesc struct was being cleaned up (last reference
is released), any record descriptors were not cleaned up. Since the
record descriptors can contain a reference to a printf descriptor as
well, those were not being cleaned up either.
We now make sure to release all allocated memory related to this.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_map.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libdtrace/dt_map.c b/libdtrace/dt_map.c
index ce11f7c9..f87b4d38 100644
--- a/libdtrace/dt_map.c
+++ b/libdtrace/dt_map.c
@@ -24,9 +24,16 @@ dt_datadesc_hold(dtrace_datadesc_t *ddp)
void
dt_datadesc_release(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp)
{
+ int i;
+ dtrace_recdesc_t *rec;
+
if (--ddp->dtdd_refcnt > 0)
return;
+ for (i = 0, rec = &ddp->dtdd_recs[0]; i < ddp->dtdd_nrecs; i++, rec++) {
+ if (rec->dtrd_format != NULL)
+ dt_printf_destroy(rec->dtrd_format);
+ }
dt_free(dtp, ddp->dtdd_recs);
dt_free(dtp, ddp);
}
--
2.26.0
More information about the DTrace-devel
mailing list