From b979a073dfbf61f4f18129ea840385b733816962 Mon Sep 17 00:00:00 2001 From: hyousatsu Date: Tue, 28 Mar 2023 02:16:17 +0000 Subject: [PATCH] dtwm: fix a segfault. --- cde/programs/dtwm/WmProperty.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cde/programs/dtwm/WmProperty.c b/cde/programs/dtwm/WmProperty.c index dd88dffc8..edbadb95c 100644 --- a/cde/programs/dtwm/WmProperty.c +++ b/cde/programs/dtwm/WmProperty.c @@ -38,6 +38,7 @@ #include "WmICCC.h" #include #include +#include #include
#include #include @@ -1954,18 +1955,20 @@ void UpdateNetWmState (Window window, Atom *states, unsigned long nstates, { int i, j, actualFormat; unsigned long nold, leftover; - Atom actualType, *oldStates, *newStates; + Atom actualType; unsigned long nnew = 0; Atom type = wmGD.xa__NET_WM_STATE; + Atom *oldStates = NULL; + Atom *newStates = NULL; + + if (!states) nstates = 0; if (!(XGetWindowProperty (DISPLAY, window, type, 0L, 1000000L, False, XA_ATOM, &actualType, &actualFormat, &nold, &leftover, (unsigned char **) &oldStates) == Success && actualType == XA_ATOM)) nold = 0; - if (!(states && nstates) && nold) goto done; - - newStates = malloc ((nstates + nold) * sizeof (Atom)); + newStates = malloc ((1 + nstates + nold) * sizeof (Atom)); if (!newStates) goto done;