]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Avoid double free in startup_inferior
authorKamil Rytarowski <n54@gmx.com>
Wed, 2 Sep 2020 17:24:05 +0000 (19:24 +0200)
committerKamil Rytarowski <n54@gmx.com>
Thu, 10 Sep 2020 13:39:19 +0000 (15:39 +0200)
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.

gdb/ChangeLog
gdb/nat/fork-inferior.c

index ecf8e37f58b9995d54eccde0496fcb33f30cc14e..80c77c2e388150ab57a797f970143d98515a3240 100644 (file)
@@ -1,3 +1,7 @@
+2020-09-10  Kamil Rytarowski  <n54@gmx.com>
+
+       * fork-inferior.c (startup_inferior): Avoid double free.
+
 2020-09-10  Kamil Rytarowski  <n54@gmx.com>
 
        * netbsd-nat.h (netbsd_nat::qxfer_siginfo): Add.
index 1185ef8998b760d8d152582d9527d34895932a20..7ba0126871dd636553f6620405eebc6c0051494d 100644 (file)
@@ -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;