summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Hunter <m@lfurio.us>2025-07-26 21:02:43 -0400
committerMatt Hunter <m@lfurio.us>2025-07-26 21:11:34 -0400
commit6921d7a374f6981b45cd41f773820cd711f417e5 (patch)
tree9ab97b9302cb308d7f253216f84a80d0abecf218
parent27bb9ccc06b715ea8f76c269e8bc2fab03110155 (diff)
downloadmisplays-6921d7a374f6981b45cd41f773820cd711f417e5.tar.gz
misplays-6921d7a374f6981b45cd41f773820cd711f417e5.zip
Fix possible segfault in dbg_detach
If dbg_attach fails, it calls this function to clean up before the process in added to the main process list, so list_remove() is invalid. Signed-off-by: Matt Hunter <m@lfurio.us>
-rw-r--r--debugger.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/debugger.c b/debugger.c
index 3902819..2bbf866 100644
--- a/debugger.c
+++ b/debugger.c
@@ -532,7 +532,9 @@ void dbg_detach(struct process *proc) {
}
free_breakpoints(proc);
- list_remove(proc);
+ if (proc->next) { /* workaround: its invalid to list_remove() if dbg_attach fails */
+ list_remove(proc);
+ }
free(proc);
}