[binutils-gdb] ld parser buffer leak
Alan Modra
amodra@sourceware.org
Thu Jan 16 22:08:29 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=64d357bc45f26eae5d8316cec740749727fa66b7
commit 64d357bc45f26eae5d8316cec740749727fa66b7
Author: Alan Modra <amodra@gmail.com>
Date: Sat Jan 11 16:16:14 2025 +1030
ld parser buffer leak
* ldlex.l (<<EOF>>): yy_delete_buffer current.
(yy_create_string_buffer): Use yyalloc.
Diff:
---
ld/ldlex.l | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ld/ldlex.l b/ld/ldlex.l
index ef0c5bdf425..f36362fefc1 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -477,6 +477,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
}
<<EOF>> {
+ yy_delete_buffer (YY_CURRENT_BUFFER);
include_stack_ptr--;
if (include_stack_ptr == 0)
{
@@ -528,13 +529,13 @@ yy_create_string_buffer (const char *string, size_t size)
{
YY_BUFFER_STATE b;
- b = xmalloc (sizeof (struct yy_buffer_state));
+ b = yyalloc (sizeof (struct yy_buffer_state));
b->yy_input_file = 0;
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
we need to put in 2 end-of-buffer characters. */
- b->yy_ch_buf = xmalloc ((size_t) b->yy_buf_size + 3);
+ b->yy_ch_buf = yyalloc (b->yy_buf_size + 3);
b->yy_ch_buf[0] = '\n';
strcpy (b->yy_ch_buf+1, string);
More information about the Binutils-cvs
mailing list