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
10cafd0bbe
commit
39f337fd49
|
@ -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;
|
||||
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++;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue