[binutils-gdb] gas: sframe: fix memory leak of remember_fre
Indu Bhagat
ibhagat@sourceware.org
Tue Dec 16 19:54:20 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=272c02e9f5e65813bbeefc9f52b0e153990ada0e
commit 272c02e9f5e65813bbeefc9f52b0e153990ada0e
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date: Tue Dec 16 11:54:07 2025 -0800
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:
---
gas/gen-sframe.c | 6 ++++++
1 file changed, 6 insertions(+)
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
More information about the Binutils-cvs
mailing list