mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-02 13:08:01 +02:00
randr: handle -Wanalyzer-null-dereference in ProcRRListProviderProperties()
Reported in #1817: xwayland-24.1.6/redhat-linux-build/../randr/rrproviderproperty.c:419:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘temppAtoms’ The NULL dereference was flagged because the compiler didn't realize that the loop to dereference the pointer would have 0 iterations if the pointer hadn't been allocated. Moving it inside the if (numProps) check made the dereference condition match the allocation condition so that the gcc static analyzer was satisfied. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2165>
This commit is contained in:
parent
3cd7892e91
commit
d7775b5682
1 changed files with 6 additions and 5 deletions
|
|
@ -391,7 +391,7 @@ int
|
|||
ProcRRListProviderProperties(ClientPtr client)
|
||||
{
|
||||
REQUEST(xRRListProviderPropertiesReq);
|
||||
Atom *pAtoms = NULL, *temppAtoms;
|
||||
Atom *pAtoms = NULL;
|
||||
xRRListProviderPropertiesReply rep;
|
||||
int numProps = 0;
|
||||
RRProviderPtr provider;
|
||||
|
|
@ -418,12 +418,13 @@ ProcRRListProviderProperties(ClientPtr client)
|
|||
swapl(&rep.length);
|
||||
swaps(&rep.nAtoms);
|
||||
}
|
||||
temppAtoms = pAtoms;
|
||||
for (prop = provider->properties; prop; prop = prop->next)
|
||||
*temppAtoms++ = prop->propertyName;
|
||||
|
||||
WriteToClient(client, sizeof(xRRListProviderPropertiesReply), (char *) &rep);
|
||||
if (numProps) {
|
||||
Atom *temppAtoms = pAtoms;
|
||||
|
||||
for (prop = provider->properties; prop; prop = prop->next)
|
||||
*temppAtoms++ = prop->propertyName;
|
||||
|
||||
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
||||
WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
|
||||
free(pAtoms);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue