This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/5] gdb: Free inferior->priv when inferior exits
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 17 Feb 2016 02:44:48 +0000
- Subject: [PATCH 2/5] gdb: Free inferior->priv when inferior exits
- Authentication-results: sourceware.org; auth=none
- References: <1455677091-13683-1-git-send-email-palves at redhat dot com>
(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-02-16 Pedro Alves <palves@redhat.com>
* inferior.c (exit_inferior_1): Free 'priv'.
---
gdb/inferior.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 45b3141..083dc63 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -255,6 +255,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;
--
1.9.3