mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-07 04:08:25 +02:00
randr: handle -Wanalyzer-null-dereference in ProcRRGetOutputInfo()
Reported in #1817: xwayland-24.1.6/redhat-linux-build/../randr/rroutput.c:540:13: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’ The NULL dereference was only theoretically possible if the sum of the sizes wrapped around to 0, but this ensures a NULL dereference won't happen even in that case. 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
f98b4e9165
commit
3cd7892e91
1 changed files with 30 additions and 27 deletions
|
|
@ -467,9 +467,6 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
unsigned long extraLen;
|
||||
ScreenPtr pScreen;
|
||||
rrScrPrivPtr pScrPriv;
|
||||
RRCrtc *crtcs;
|
||||
RRMode *modes;
|
||||
RROutput *clones;
|
||||
char *name;
|
||||
int i;
|
||||
Bool leased;
|
||||
|
|
@ -534,36 +531,42 @@ ProcRRGetOutputInfo(ClientPtr client)
|
|||
output->numClones + bytes_to_int32(rep.nameLength)) << 2);
|
||||
|
||||
if (extraLen) {
|
||||
RRCrtc *crtcs;
|
||||
RRMode *modes;
|
||||
RROutput *clones;
|
||||
|
||||
rep.length += bytes_to_int32(extraLen);
|
||||
extra = calloc(1, extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||
clones = (RROutput *) (modes + output->numModes + output->numUserModes);
|
||||
name = (char *) (clones + output->numClones);
|
||||
|
||||
for (i = 0; i < output->numCrtcs; i++) {
|
||||
crtcs[i] = output->crtcs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl(&crtcs[i]);
|
||||
}
|
||||
for (i = 0; i < output->numModes + output->numUserModes; i++) {
|
||||
if (i < output->numModes)
|
||||
modes[i] = output->modes[i]->mode.id;
|
||||
else
|
||||
modes[i] = output->userModes[i - output->numModes]->mode.id;
|
||||
if (client->swapped)
|
||||
swapl(&modes[i]);
|
||||
}
|
||||
for (i = 0; i < output->numClones; i++) {
|
||||
clones[i] = output->clones[i]->id;
|
||||
if (client->swapped)
|
||||
swapl(&clones[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
extra = NULL;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||
clones = (RROutput *) (modes + output->numModes + output->numUserModes);
|
||||
name = (char *) (clones + output->numClones);
|
||||
|
||||
for (i = 0; i < output->numCrtcs; i++) {
|
||||
crtcs[i] = output->crtcs[i]->id;
|
||||
if (client->swapped)
|
||||
swapl(&crtcs[i]);
|
||||
}
|
||||
for (i = 0; i < output->numModes + output->numUserModes; i++) {
|
||||
if (i < output->numModes)
|
||||
modes[i] = output->modes[i]->mode.id;
|
||||
else
|
||||
modes[i] = output->userModes[i - output->numModes]->mode.id;
|
||||
if (client->swapped)
|
||||
swapl(&modes[i]);
|
||||
}
|
||||
for (i = 0; i < output->numClones; i++) {
|
||||
clones[i] = output->clones[i]->id;
|
||||
if (client->swapped)
|
||||
swapl(&clones[i]);
|
||||
name = NULL;
|
||||
}
|
||||
}
|
||||
memcpy(name, output->name, output->nameLength);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue