xfree86: protect from memory allocation failure
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
ea618f9bff
commit
75dc221459
|
@ -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];
|
||||||
|
@ -398,6 +400,10 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
|
||||||
while (modes[i] != 0xffff)
|
while (modes[i] != 0xffff)
|
||||||
i++;
|
i++;
|
||||||
block->VideoModePtr = calloc(i + 1, sizeof(CARD16));
|
block->VideoModePtr = calloc(i + 1, sizeof(CARD16));
|
||||||
|
if (!(block->VideoModePtr)) {
|
||||||
|
free(block);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
|
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
|
||||||
block->VideoModePtr[i] = 0xffff;
|
block->VideoModePtr[i] = 0xffff;
|
||||||
|
|
||||||
|
@ -826,6 +832,8 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
data = calloc(num, sizeof(CARD32));
|
data = calloc(num, sizeof(CARD32));
|
||||||
|
if (!data)
|
||||||
|
return NULL;
|
||||||
memcpy(data, pVbe->memory, num * sizeof(CARD32));
|
memcpy(data, pVbe->memory, num * sizeof(CARD32));
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -1154,6 +1154,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))
|
||||||
|
@ -1653,6 +1655,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