This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: copy argument text in gdb.execute
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 09 Nov 2009 11:27:32 -0700
- Subject: FYI: copy argument text in gdb.execute
- Reply-to: tromey at redhat dot com
I'm checking this in.
This fixes the bug recently reported on the gdb list.
execute_gdb_command must copy its argument text in case the called gdb
command modifies it.
Tom
2009-11-09 Tom Tromey <tromey@redhat.com>
* python/python.c (execute_gdb_command): Copy the argument text.
Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.19
diff -u -r1.19 python.c
--- python/python.c 2 Jul 2009 17:04:23 -0000 1.19
+++ python/python.c 9 Nov 2009 18:25:25 -0000
@@ -309,7 +309,11 @@
TRY_CATCH (except, RETURN_MASK_ALL)
{
- execute_command (arg, from_tty);
+ /* Copy the argument text in case the command modifies it. */
+ char *copy = xstrdup (arg);
+ struct cleanup *cleanup = make_cleanup (xfree, copy);
+ execute_command (copy, from_tty);
+ do_cleanups (cleanup);
}
GDB_PY_HANDLE_EXCEPTION (except);