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:
parent
e99a8f18ef
commit
6a1fa5cf13
|
@ -643,17 +643,20 @@ ProcListProperties(ClientPtr client)
|
||||||
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
|
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
|
||||||
numProps++;
|
numProps++;
|
||||||
|
|
||||||
if (numProps && !(pAtoms = xallocarray(numProps, sizeof(Atom))))
|
if (numProps) {
|
||||||
return BadAlloc;
|
pAtoms = xallocarray(numProps, sizeof(Atom));
|
||||||
|
if (!pAtoms)
|
||||||
|
return BadAlloc;
|
||||||
|
|
||||||
numProps = 0;
|
numProps = 0;
|
||||||
temppAtoms = pAtoms;
|
temppAtoms = pAtoms;
|
||||||
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) {
|
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) {
|
||||||
realProp = pProp;
|
realProp = pProp;
|
||||||
rc = XaceHookPropertyAccess(client, pWin, &realProp, DixGetAttrAccess);
|
rc = XaceHookPropertyAccess(client, pWin, &realProp, DixGetAttrAccess);
|
||||||
if (rc == Success && realProp == pProp) {
|
if (rc == Success && realProp == pProp) {
|
||||||
*temppAtoms++ = pProp->propertyName;
|
*temppAtoms++ = pProp->propertyName;
|
||||||
numProps++;
|
numProps++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,8 +670,8 @@ ProcListProperties(ClientPtr client)
|
||||||
if (numProps) {
|
if (numProps) {
|
||||||
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
||||||
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
||||||
|
free(pAtoms);
|
||||||
}
|
}
|
||||||
free(pAtoms);
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue