This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

spu malloc fix

When running the spu-elf testsuite my new x86_64 box is spitting out
*** glibc detected *** ./ld-new: free(): invalid next size (fast): 0x0000000001c45af0 ***

I don't know why this never showed up before on the older x86 machine,
likely the older version of glibc on that box had different malloc /
free.  Curiously, this problem doesn't show up on bigendian hosts
like powerpc64, the usual host for spu targetted binutils.  That's
because the NUL string terminator overwrites the most significant byte
of the size, which happens to be zero already.

	* elf32-spu.c (build_stub): Fix malloc under-allocation.

Index: bfd/elf32-spu.c
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.102
diff -u -p -r1.102 elf32-spu.c
--- bfd/elf32-spu.c	19 Oct 2011 07:17:18 -0000	1.102
+++ bfd/elf32-spu.c	26 Feb 2012 03:49:08 -0000
@@ -1425,7 +1425,7 @@ build_stub (struct bfd_link_info *info,
 	add = (int) irela->r_addend & 0xffffffff;
       if (add != 0)
 	len += 1 + 8;
-      name = bfd_malloc (len);
+      name = bfd_malloc (len + 1);
       if (name == NULL)
 	return FALSE;

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]