* [PATCH] gas: Fix a CFI label name memory leak in scfi.c
@ 2024-04-09 23:04 H.J. Lu
2024-04-11 2:09 ` Indu Bhagat
0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-04-09 23:04 UTC (permalink / raw)
To: binutils; +Cc: indu.bhagat
CFI label name can be freed only after use.
* scfi.c (handle_scfi_dot_cfi): Free CFI label name after use.
* scfidw2gen.c (scfi_process_cfi_label): Add a comment. Remove
TODO on freeing CFI label name.
---
gas/scfi.c | 1 +
gas/scfidw2gen.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gas/scfi.c b/gas/scfi.c
index 37cc85cfed7..f34150cb08a 100644
--- a/gas/scfi.c
+++ b/gas/scfi.c
@@ -1137,6 +1137,7 @@ handle_scfi_dot_cfi (ginsnS *ginsn)
break;
case CFI_label:
scfi_dot_cfi (CFI_label, 0, 0, 0, op->op_data->name, ginsn->sym);
+ free ((char *) op->op_data->name);
break;
case CFI_signal_frame:
scfi_dot_cfi (CFI_signal_frame, 0, 0, 0, NULL, ginsn->sym);
diff --git a/gas/scfidw2gen.c b/gas/scfidw2gen.c
index ebf2d24dab2..2b018fac8bd 100644
--- a/gas/scfidw2gen.c
+++ b/gas/scfidw2gen.c
@@ -57,8 +57,8 @@ scfi_process_cfi_label (void)
frch_ginsn_data_append (ginsn);
scfi_op_add_cfi_label (ginsn, name);
- /* TODO. */
- // free (name);
+ /* NB: Can't free NAME here since it will be used later. Free it in
+ handle_scfi_dot_cfi after it is unused. */
demand_empty_rest_of_line ();
}
--
2.44.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gas: Fix a CFI label name memory leak in scfi.c
2024-04-09 23:04 [PATCH] gas: Fix a CFI label name memory leak in scfi.c H.J. Lu
@ 2024-04-11 2:09 ` Indu Bhagat
0 siblings, 0 replies; 2+ messages in thread
From: Indu Bhagat @ 2024-04-11 2:09 UTC (permalink / raw)
To: H.J. Lu, binutils
On 4/9/24 16:04, H.J. Lu wrote:
> CFI label name can be freed only after use.
>
> * scfi.c (handle_scfi_dot_cfi): Free CFI label name after use.
> * scfidw2gen.c (scfi_process_cfi_label): Add a comment. Remove
> TODO on freeing CFI label name.
Thanks for the patch.
> ---
> gas/scfi.c | 1 +
> gas/scfidw2gen.c | 4 ++--
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gas/scfi.c b/gas/scfi.c
> index 37cc85cfed7..f34150cb08a 100644
> --- a/gas/scfi.c
> +++ b/gas/scfi.c
> @@ -1137,6 +1137,7 @@ handle_scfi_dot_cfi (ginsnS *ginsn)
> break;
> case CFI_label:
> scfi_dot_cfi (CFI_label, 0, 0, 0, op->op_data->name, ginsn->sym);
> + free ((char *) op->op_data->name);
> break;
> case CFI_signal_frame:
> scfi_dot_cfi (CFI_signal_frame, 0, 0, 0, NULL, ginsn->sym);
> diff --git a/gas/scfidw2gen.c b/gas/scfidw2gen.c
> index ebf2d24dab2..2b018fac8bd 100644
> --- a/gas/scfidw2gen.c
> +++ b/gas/scfidw2gen.c
> @@ -57,8 +57,8 @@ scfi_process_cfi_label (void)
> frch_ginsn_data_append (ginsn);
>
> scfi_op_add_cfi_label (ginsn, name);
> - /* TODO. */
> - // free (name);
> + /* NB: Can't free NAME here since it will be used later. Free it in
> + handle_scfi_dot_cfi after it is unused. */
>
> demand_empty_rest_of_line ();
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-11 2:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 23:04 [PATCH] gas: Fix a CFI label name memory leak in scfi.c H.J. Lu
2024-04-11 2:09 ` Indu Bhagat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).