diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-09-08 11:15:03 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-09-08 11:48:18 -0700 |
commit | 39f337fd497d6fd95efaae9ff5a62d60b49e16aa (patch) | |
tree | c7c05ac0a98db3397f62fc0efcc5df93ef80156c /dix | |
parent | 10cafd0bbebfbb92c4e73088ba168ef96fcb983c (diff) |
dix: ProcListProperties: skip unneeded work if numProps is 0
No real harm, but clears warning from gcc 14.1:
../dix/property.c: In function ‘ProcListProperties’:
..//dix/property.c:605:27: warning: dereference of NULL ‘temppAtoms’
[CWE-476] [-Wanalyzer-null-dereference]
605 | *temppAtoms++ = pProp->propertyName;
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1673>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/property.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/dix/property.c b/dix/property.c index b51b371f0..501c54698 100644 --- a/dix/property.c +++ b/dix/property.c @@ -593,17 +593,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++; + } } } @@ -617,8 +620,8 @@ ProcListProperties(ClientPtr client) if (numProps) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); + free(pAtoms); } - free(pAtoms); return Success; } |