This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[vms/committed]: Fix memory leak in tc-alpha.c
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils Development <binutils at sourceware dot org>
- Date: Tue, 28 Jun 2011 11:23:31 +0200
- Subject: [vms/committed]: Fix memory leak in tc-alpha.c
Hi,
there were several use of xmalloc without matching free in gas/config/tc-alpha.c for vms.
Using xmalloc isn't necessary and this patch replaces them with alloca.
Applied on trunk.
Tristan.
gas/
2011-06-28 Tristan Gingold <gingold@adacore.com>
* config/tc-alpha.c (load_expression): Use alloca instead of xmalloc.
(emit_jsrjmp): Ditto.
(tc_gen_reloc): Ditto.
Index: config/tc-alpha.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.c,v
retrieving revision 1.93
diff -c -r1.93 tc-alpha.c
*** config/tc-alpha.c 28 Jun 2011 07:40:16 -0000 1.93
--- config/tc-alpha.c 28 Jun 2011 09:19:11 -0000
***************
*** 1387,1393 ****
ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2)
ptr1 = symname;
! ensymname = (char *) xmalloc (ptr2 - ptr1 + 5);
memcpy (ensymname, ptr1, ptr2 - ptr1);
memcpy (ensymname + (ptr2 - ptr1), "..en", 5);
--- 1387,1393 ----
ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2)
ptr1 = symname;
! ensymname = (char *) alloca (ptr2 - ptr1 + 5);
memcpy (ensymname, ptr1, ptr2 - ptr1);
memcpy (ensymname + (ptr2 - ptr1), "..en", 5);
***************
*** 1419,1425 ****
ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2)
ptr1 = symname;
! psymname = (char *) xmalloc (ptr2 - ptr1 + 1);
memcpy (psymname, ptr1, ptr2 - ptr1);
psymname [ptr2 - ptr1] = 0;
--- 1419,1425 ----
ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2)
ptr1 = symname;
! psymname = (char *) alloca (ptr2 - ptr1 + 1);
memcpy (psymname, ptr1, ptr2 - ptr1);
psymname [ptr2 - ptr1] = 0;
***************
*** 2884,2890 ****
char *ensymname;
/* Build the entry name as 'NAME..en'. */
! ensymname = (char *) xmalloc (symlen + 5);
memcpy (ensymname, symname, symlen);
memcpy (ensymname + symlen, "..en", 5);
--- 2884,2890 ----
char *ensymname;
/* Build the entry name as 'NAME..en'. */
! ensymname = (char *) alloca (symlen + 5);
memcpy (ensymname, symname, symlen);
memcpy (ensymname + symlen, "..en", 5);
***************
*** 6282,6292 ****
if (pname_len > 4 && strcmp (pname + pname_len - 4, "..en") == 0)
{
symbolS *sym;
! char *my_pname = xstrdup (pname);
my_pname [pname_len - 4] = 0;
sym = symbol_find (my_pname);
if (sym == NULL)
abort ();
while (symbol_equated_reloc_p (sym))
{
symbolS *n = symbol_get_value_expression (sym)->X_add_symbol;
--- 6282,6295 ----
if (pname_len > 4 && strcmp (pname + pname_len - 4, "..en") == 0)
{
symbolS *sym;
! char *my_pname = (char *) alloca (pname_len - 4 + 1);
!
! memcpy (my_pname, pname, pname_len - 4);
my_pname [pname_len - 4] = 0;
sym = symbol_find (my_pname);
if (sym == NULL)
abort ();
+
while (symbol_equated_reloc_p (sym))
{
symbolS *n = symbol_get_value_expression (sym)->X_add_symbol;