From f05bc54cebf35b2ba850a677ad38148304746720 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Thu, 19 Aug 2021 21:49:03 +0800 Subject: [PATCH] dtwm: To avoid a segfault, allocate gadget rectangles when regenerate window frame. A typical case, create a frameless window then regenerate it's frame. --- cde/programs/dtwm/WmCDInfo.c | 5 +++-- cde/programs/dtwm/WmCDecor.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cde/programs/dtwm/WmCDInfo.c b/cde/programs/dtwm/WmCDInfo.c index dbe26d294..3027701f9 100644 --- a/cde/programs/dtwm/WmCDInfo.c +++ b/cde/programs/dtwm/WmCDInfo.c @@ -989,7 +989,8 @@ int IdentifyFramePart (ClientData *pCD, int x, int y) if (decor & MWM_DECOR_TITLE) { - if ( (x >= pCD->titleRectangle.x) && + if ( pCD->pTitleGadgets && + (x >= pCD->titleRectangle.x) && (x < (int)pCD->titleRectangle.x + (int)pCD->titleRectangle.width) && (y >= pCD->titleRectangle.y) && (y < (int)pCD->titleRectangle.y + (int)pCD->titleRectangle.height) ) @@ -1002,7 +1003,7 @@ int IdentifyFramePart (ClientData *pCD, int x, int y) /* try resize border */ - if (decor & MWM_DECOR_RESIZEH) + if (decor & MWM_DECOR_RESIZEH && pCD->pTitleGadgets) { rval = GadgetID(x, y, pCD->pResizeGadgets, STRETCH_COUNT); } diff --git a/cde/programs/dtwm/WmCDecor.c b/cde/programs/dtwm/WmCDecor.c index c8d6f3a79..fbd73999c 100644 --- a/cde/programs/dtwm/WmCDecor.c +++ b/cde/programs/dtwm/WmCDecor.c @@ -2335,6 +2335,7 @@ void RegenerateClientFrame (ClientData *pcd) } /* recreate gadget rectangles */ + AllocateGadgetRectangles (pcd); ComputeGadgetRectangles (pcd); /* regenerate the graphics */