xfree86: protect from memory allocation failure
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
901132b766
commit
f203f3f1f1
|
@ -375,6 +375,8 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
block = calloc(1, sizeof(VbeInfoBlock));
|
block = calloc(1, sizeof(VbeInfoBlock));
|
||||||
|
if (!block)
|
||||||
|
return NULL;
|
||||||
block->VESASignature[0] = ((char *) pVbe->memory)[0];
|
block->VESASignature[0] = ((char *) pVbe->memory)[0];
|
||||||
block->VESASignature[1] = ((char *) pVbe->memory)[1];
|
block->VESASignature[1] = ((char *) pVbe->memory)[1];
|
||||||
block->VESASignature[2] = ((char *) pVbe->memory)[2];
|
block->VESASignature[2] = ((char *) pVbe->memory)[2];
|
||||||
|
@ -397,7 +399,8 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
|
||||||
i = 0;
|
i = 0;
|
||||||
while (modes[i] != 0xffff)
|
while (modes[i] != 0xffff)
|
||||||
i++;
|
i++;
|
||||||
block->VideoModePtr = calloc(i + 1, sizeof(CARD16));
|
if (!(block->VideoModePtr = calloc(i + 1, sizeof(CARD16))))
|
||||||
|
return NULL;
|
||||||
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
|
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
|
||||||
block->VideoModePtr[i] = 0xffff;
|
block->VideoModePtr[i] = 0xffff;
|
||||||
|
|
||||||
|
@ -806,7 +809,8 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
|
||||||
if (set)
|
if (set)
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data = calloc(num, sizeof(CARD32));
|
if (!(data = calloc(num, sizeof(CARD32))))
|
||||||
|
return NULL;
|
||||||
memcpy(data, pVbe->memory, num * sizeof(CARD32));
|
memcpy(data, pVbe->memory, num * sizeof(CARD32));
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -1153,6 +1153,8 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
save_crtcs = calloc(config->num_output, sizeof(xf86CrtcPtr));
|
save_crtcs = calloc(config->num_output, sizeof(xf86CrtcPtr));
|
||||||
|
if (!save_crtcs)
|
||||||
|
return FALSE;
|
||||||
if ((randr_mode != NULL) != crtc->enabled)
|
if ((randr_mode != NULL) != crtc->enabled)
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
else if (randr_mode && !xf86RandRModeMatches(randr_mode, &crtc->mode))
|
else if (randr_mode && !xf86RandRModeMatches(randr_mode, &crtc->mode))
|
||||||
|
@ -1652,6 +1654,11 @@ xf86RandR12SetInfo12(ScreenPtr pScreen)
|
||||||
|
|
||||||
clones = calloc(config->num_output, sizeof(RROutputPtr));
|
clones = calloc(config->num_output, sizeof(RROutputPtr));
|
||||||
crtcs = calloc(config->num_crtc, sizeof(RRCrtcPtr));
|
crtcs = calloc(config->num_crtc, sizeof(RRCrtcPtr));
|
||||||
|
if (!clones || !crtcs) {
|
||||||
|
free(clones);
|
||||||
|
free(crtcs);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
for (o = 0; o < config->num_output; o++) {
|
for (o = 0; o < config->num_output; o++) {
|
||||||
xf86OutputPtr output = config->output[o];
|
xf86OutputPtr output = config->output[o];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue