diff options
Diffstat (limited to 'xserver/dix/property.c')
-rw-r--r-- | xserver/dix/property.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/xserver/dix/property.c b/xserver/dix/property.c index acce94b2c..3eca8615a 100644 --- a/xserver/dix/property.c +++ b/xserver/dix/property.c @@ -276,11 +276,13 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, if (!pProp) return BadAlloc; data = malloc(totalSize); - if (!data && len) { - dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); - return BadAlloc; + if (totalSize) { + if (!data) { + dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); + return BadAlloc; + } + memcpy(data, value, totalSize); } - memcpy(data, value, totalSize); pProp->propertyName = property; pProp->type = type; pProp->format = format; @@ -313,9 +315,11 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, if (mode == PropModeReplace) { data = malloc(totalSize); - if (!data && len) - return BadAlloc; - memcpy(data, value, totalSize); + if (totalSize) { + if (!data) + return BadAlloc; + memcpy(data, value, totalSize); + } pProp->data = data; pProp->size = len; pProp->type = type; @@ -585,17 +589,20 @@ ProcListProperties(ClientPtr client) for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) numProps++; - if (numProps && !(pAtoms = xallocarray(numProps, sizeof(Atom)))) - return BadAlloc; - - numProps = 0; - temppAtoms = pAtoms; - for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) { - realProp = pProp; - rc = XaceHookPropertyAccess(client, pWin, &realProp, DixGetAttrAccess); - if (rc == Success && realProp == pProp) { - *temppAtoms++ = pProp->propertyName; - numProps++; + if (numProps) { + pAtoms = xallocarray(numProps, sizeof(Atom)); + if (!pAtoms) + return BadAlloc; + + numProps = 0; + temppAtoms = pAtoms; + for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) { + realProp = pProp; + rc = XaceHookPropertyAccess(client, pWin, &realProp, DixGetAttrAccess); + if (rc == Success && realProp == pProp) { + *temppAtoms++ = pProp->propertyName; + numProps++; + } } } @@ -609,8 +616,8 @@ ProcListProperties(ClientPtr client) if (numProps) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); + free(pAtoms); } - free(pAtoms); return Success; } |