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>
This commit is contained in:
Alan Coopersmith 2024-09-08 11:15:03 -07:00 committed by Enrico Weigelt, metux IT consult
parent e99a8f18ef
commit 6a1fa5cf13

View File

@ -643,7 +643,9 @@ ProcListProperties(ClientPtr client)
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
numProps++;
if (numProps && !(pAtoms = xallocarray(numProps, sizeof(Atom))))
if (numProps) {
pAtoms = xallocarray(numProps, sizeof(Atom));
if (!pAtoms)
return BadAlloc;
numProps = 0;
@ -656,6 +658,7 @@ ProcListProperties(ClientPtr client)
numProps++;
}
}
}
xlpr = (xListPropertiesReply) {
.type = X_Reply,
@ -667,8 +670,8 @@ ProcListProperties(ClientPtr client)
if (numProps) {
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
}
free(pAtoms);
}
return Success;
}