diff options
author | Kamil Rytarowski <n54@gmx.com> | 2020-09-02 19:24:05 +0200 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2020-09-10 15:39:19 +0200 |
commit | f404573e4f8d22f0f1f87eee4f08fa132b15a9aa (patch) | |
tree | 6c1545a3c6eba6083081df0d5af4e0098e20410e /gdb/nat | |
parent | 1ccb2c170cea50671f7aa00eb6a2be2a33ea24a5 (diff) | |
download | gdb-f404573e4f8d22f0f1f87eee4f08fa132b15a9aa.zip gdb-f404573e4f8d22f0f1f87eee4f08fa132b15a9aa.tar.gz gdb-f404573e4f8d22f0f1f87eee4f08fa132b15a9aa.tar.bz2 |
Avoid double free in startup_inferior
Do not free the last execd pathname as it will be used in
prepare_resume_reply(), after attaching a client side.
gdb/ChangeLog:
* fork-inferior.c (startup_inferior): Avoid double free.
Diffstat (limited to 'gdb/nat')
-rw-r--r-- | gdb/nat/fork-inferior.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c index 1185ef8..7ba0126 100644 --- a/gdb/nat/fork-inferior.c +++ b/gdb/nat/fork-inferior.c @@ -526,7 +526,10 @@ startup_inferior (process_stratum_target *proc_target, pid_t pid, int ntraps, case TARGET_WAITKIND_EXECD: /* Handle EXEC signals as if they were SIGTRAP signals. */ - xfree (ws.value.execd_pathname); + /* Free the exec'ed pathname, but only if this isn't the + waitstatus we are returning to the caller. */ + if (pending_execs != 1) + xfree (ws.value.execd_pathname); resume_signal = GDB_SIGNAL_TRAP; switch_to_thread (proc_target, event_ptid); break; |