From f5837878259bb43960c247b4fc5604e65705b7a8 Mon Sep 17 00:00:00 2001 From: Ingo Paschke Date: Tue, 12 May 2026 11:12:40 +0200 Subject: [PATCH] Amiga: fix overview-window crashes - MyAllocBitMap left bm->mflags uninitialized, so MyFreeBitMap took the wrong path between FreeRaster and FreeMem and intermittently corrupted exec's free list (Software Failure 0x81000005, DEADEND in FreeMem). - The NHW_OVER window is BORDERLESS, so attaching WINDOWSIZING | WINDOWDRAG | WINDOWCLOSE created phantom gadgets that hit-test against unrelated input. Pressing ESC while the overview was selected fired CLOSEWINDOW and destroyed the window underneath the running code, leading to wild-PC crashes. Drop the gadget flags; SHIFT-HELP already toggles the overview cleanly via delayed_key_action. - amii_destroy_nhwindow only reset WIN_MAP / WIN_STATUS / WIN_MESSAGE / WIN_INVEN; WIN_OVER and WIN_BASE kept pointing at freed slots, so any later 'WIN_X != WIN_ERR && amii_wins[WIN_X]->win' check dereferenced NULL. Reset them too. --- sys/amiga/winchar.c | 1 + sys/amiga/winfuncs.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/amiga/winchar.c b/sys/amiga/winchar.c index 8980bdf55..b84561311 100644 --- a/sys/amiga/winchar.c +++ b/sys/amiga/winchar.c @@ -189,6 +189,7 @@ MyAllocBitMap(int xsize, int ysize, int depth, long mflags) if (!bm) return (NULL); + bm->mflags = mflags; bm->xsize = xsize; bm->ysize = ysize; InitBitMap(&bm->bm, depth, xsize, ysize); diff --git a/sys/amiga/winfuncs.c b/sys/amiga/winfuncs.c index 3af760edb..9b172201d 100644 --- a/sys/amiga/winfuncs.c +++ b/sys/amiga/winfuncs.c @@ -227,6 +227,10 @@ amii_destroy_nhwindow(winid win) /* just hide */ WIN_MESSAGE = WIN_ERR; else if (win == WIN_INVEN) WIN_INVEN = WIN_ERR; + else if (win == WIN_OVER) + WIN_OVER = WIN_ERR; + else if (win == WIN_BASE) + WIN_BASE = WIN_ERR; } struct FillParams { @@ -416,8 +420,13 @@ amii_create_nhwindow(int type) if (nw->Width >= amiIDisplay->xpix - nw->LeftEdge) nw->Width = amiIDisplay->xpix - nw->LeftEdge; } else if (WINVERS_AMIV && type == NHW_OVER) { - nw->Flags |= WINDOWSIZING | WINDOWDRAG | WINDOWCLOSE; - nw->IDCMPFlags |= CLOSEWINDOW; + /* No window-system gadgets: BORDERLESS means there is no border + * to attach close/size/drag gadgets to. On some Kickstarts the + * phantom gadgets hit-test against unrelated input (selecting + * the overview and pressing ESC has been observed to destroy + * the window and crash the game). SHIFT-HELP toggles the + * overview cleanly via delayed_key_action; that is the + * supported close path. */ /* Bring up window as half the width of the message window, and make * the message window change to one half the width... */