From 6921d7a374f6981b45cd41f773820cd711f417e5 Mon Sep 17 00:00:00 2001 From: Matt Hunter Date: Sat, 26 Jul 2025 21:02:43 -0400 Subject: 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 --- debugger.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3