From: Indu Bhagat Date: Tue, 16 Dec 2025 19:54:07 +0000 (-0800) Subject: gas: sframe: fix memory leak of remember_fre X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=272c02e9f5e65813bbeefc9f52b0e153990ada0e;p=thirdparty%2Fbinutils-gdb.git gas: sframe: fix memory leak of remember_fre While at it, use the same pattern for cleaning up memory in sframe_xlate_ctx_cleanup. gas/ * gen-sframe.c (sframe_xlate_ctx_cleanup): Use the same pattern for free'ing memory consistently. (sframe_xlate_ctx_finalize): Free up remember_fre. --- diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 0d6edd362cb..f31cbaee060 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -924,7 +924,9 @@ sframe_xlate_ctx_cleanup (struct sframe_xlate_ctx *xlate_ctx) { sframe_row_entry_free (xlate_ctx->first_fre); XDELETE (xlate_ctx->remember_fre); + xlate_ctx->remember_fre = NULL; XDELETE (xlate_ctx->cur_fre); + xlate_ctx->cur_fre = NULL; } /* Transfer the state from the SFrame translation context to the SFrame FDE. */ @@ -936,6 +938,10 @@ sframe_xlate_ctx_finalize (struct sframe_xlate_ctx *xlate_ctx, sframe_fde->dw_fde = xlate_ctx->dw_fde; sframe_fde->sframe_fres = xlate_ctx->first_fre; sframe_fde->num_fres = xlate_ctx->num_xlate_fres; + /* remember_fre is cloned copy of the applicable fre (where necessary). + Since this is not included in the list of sframe_fres, free it. */ + XDELETE (xlate_ctx->remember_fre); + xlate_ctx->remember_fre = NULL; } /* Add the given FRE in the list of frame row entries in the given FDE