This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[PATCH] Fix copy of filename in bfd's filename field


Hi,

in my recent tests, upstream gdb was crashing with the following:

$ ./gdb ./testsuite/gdb.base/break -q -ex run
Reading symbols from ./testsuite/gdb.base/break...done.
Starting program:
/home/emachado/devel/gdb/binutils-gdb.git/build/gdb/testsuite/gdb.base/break 
*** glibc detected *** ./gdb: double free or corruption (out): 0x088efc80 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb72c9ee2]
./gdb[0x83583e9]
./gdb(bfd_close+0x99)[0x8358c81]
./gdb[0x821ba50]
...

It was caused by this commit 1be509 on binutils code
(https://sourceware.org/ml/binutils-cvs/2014-01/msg00003.html)
which is now using xstrdup to store a copy of filename in bfd struct.

The patch below fixes this problem on gdb side. Ok?

Thanks,
--
Edjunior

gdb/
2014-01-03  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* gdb_bfd.c (gdb_bfd_stash_filename): Fix copy of filename in bfd's
	filename field using xstrdup.

---
 gdb/gdb_bfd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 36c4630..1b290c2 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -69,7 +69,7 @@ gdb_bfd_stash_filename (struct bfd *abfd)
   strcpy (data, name);
 
   /* Unwarranted chumminess with BFD.  */
-  abfd->filename = data;
+  abfd->filename = xstrdup (data);
 }
 
 /* An object of this type is stored in each BFD's user data.  */
-- 
1.7.9.5


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