Skip to content

Commit

Permalink
cg: fix tstring leak in translator members that yield string values
Browse files Browse the repository at this point in the history
When a translator member yields a string value, the tstring holding the
value was not properly tracked.  This resulted in an assertion failure
in test/demo/ip/ipproto.d.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed Aug 18, 2023
1 parent a15fc60 commit dfdc399
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,6 @@ dt_cg_tstring_xalloc(dt_pcb_t *pcb)

assert(i < DT_TSTRING_SLOTS);
ts->in_use = 1;

return ts->offset;
}

Expand Down Expand Up @@ -6454,6 +6453,11 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)

dt_cg_node(mnp->dn_membexpr, dlp, drp);
dnp->dn_reg = mnp->dn_membexpr->dn_reg;

/* Move tstring (if any) to dnp. */
dnp->dn_tstring = mnp->dn_membexpr->dn_tstring;
mnp->dn_membexpr->dn_tstring = NULL;

dt_cg_typecast(mnp->dn_membexpr, dnp, dlp, drp);

dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG;
Expand Down

0 comments on commit dfdc399

Please sign in to comment.