This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] gdb: Free inferior->priv when inferior exits
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 26 Oct 2016 15:30:41 -0000
- Subject: [binutils-gdb] gdb: Free inferior->priv when inferior exits
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef4a339527a41802fbab70af25d6e4788f35dcc8
commit ef4a339527a41802fbab70af25d6e4788f35dcc8
Author: Pedro Alves <palves@redhat.com>
Date: Wed Oct 26 11:08:26 2016 +0100
gdb: Free inferior->priv when inferior exits
(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'.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/inferior.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f4c06f8..f8296b6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
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
from ...
(remote_resume): ... this. Always try vCont first.
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 1602483..250603c 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -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;