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;