gdb: Free inferior->priv when inferior exits
authorPedro Alves <palves@redhat.com>
Wed, 26 Oct 2016 10:08:26 +0000 (11:08 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 26 Oct 2016 15:21:40 +0000 (16:21 +0100)
(Where "exits" includes being killed or detached.)

Nothing is clearing inferior->priv currently.  This is a problem if we
change the inferior's process_stratum targets in a single debug
session.  This field is currently only used by darwin-nat.c, but a
follow up patch will make remote.c use it too.  Without the fix,
remote.c might end up mistaking the priv object allocated by
darwin-nat.c with its own.

(Found by inspection.)

gdb/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

* inferior.c (exit_inferior_1): Free 'priv'.

gdb/ChangeLog
gdb/inferior.c

index f4c06f8b49423678fd9e644a227be2764b494a0d..f8296b6fd8140780b2b63a696f040c637e992cdc 100644 (file)
@@ -1,3 +1,7 @@
+2016-10-26  Pedro Alves  <palves@redhat.com>
+
+       * inferior.c (exit_inferior_1): Free 'priv'.
+
 2016-10-26  Pedro Alves  <palves@redhat.com>
 
        * remote.c (remote_resume_with_hc): New function, factored out
index 16024839836be8a0339b6bd51c45c3a3126c8c1c..250603c85cc94508c3d0e191abce4d6d7bfb0f92 100644 (file)
@@ -253,6 +253,9 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
 
   inf->pid = 0;
   inf->fake_pid_p = 0;
+  xfree (inf->priv);
+  inf->priv = NULL;
+
   if (inf->vfork_parent != NULL)
     {
       inf->vfork_parent->vfork_child = NULL;