public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* spu malloc fix
@ 2012-02-26 22:54 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2012-02-26 22:54 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-26 22:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-26 22:54 spu malloc fix Alan Modra

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).