]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix memory corruption in Guile command interface
authorAndy Wingo <wingo@igalia.com>
Wed, 11 Mar 2015 13:25:29 +0000 (14:25 +0100)
committerAndy Wingo <wingo@igalia.com>
Wed, 11 Mar 2015 13:25:29 +0000 (14:25 +0100)
Re-registering a command will delete previous commands of the same name,
running the destroyer for the command object.  The Guile destroyer
incorrectly tried to xfree the name and other strings, which is invalid
as they are on the GC heap.

gdb/ChangeLog:

* guile/scm-cmd.c (cmdscm_destroyer): Don't xfree the name and
other strings, as these are on the GC'd heap, and will be
collected along with the smob.

gdb/ChangeLog
gdb/guile/scm-cmd.c

index 38d30051e6dbfc5cc7911fe12019d2ee7c67a46a..4066a793d0b6ba71f941737c81987bbb709cfdea 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-11  Andy Wingo  <wingo@igalia.com>
+
+       * guile/scm-cmd.c (cmdscm_destroyer): Don't xfree the name and
+       other strings, as these are on the GC'd heap, and will be
+       collected along with the smob.
+
 2015-03-11  Andy Wingo  <wingo@igalia.com>
 
        * guile/scm-objfile.c (gdbscm_objfile_progspace): New function.
index c870fcc9e28de23fe0cc7ccfc2478bcfa67d189a..202721bb6d5244853dc9207a1abd41532b4c671b 100644 (file)
@@ -286,11 +286,6 @@ cmdscm_destroyer (struct cmd_list_element *self, void *context)
   command_smob *c_smob = (command_smob *) context;
 
   cmdscm_release_command (c_smob);
-
-  /* We allocated the name, doc string, and perhaps the prefix name.  */
-  xfree ((char *) self->name);
-  xfree ((char *) self->doc);
-  xfree ((char *) self->prefixname);
 }
 
 /* Called by gdb to invoke the command.  */