Avoid calling xalloc(0). Change rrScreenSizeSet to rrScreenSetSize.
This commit is contained in:
parent
ef1f3248cb
commit
d08718d8fd
|
@ -198,7 +198,7 @@ Bool RRScreenInit(ScreenPtr pScreen)
|
|||
pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height;
|
||||
|
||||
#if RANDR_12_INTERFACE
|
||||
pScrPriv->rrScreenSizeSet = NULL;
|
||||
pScrPriv->rrScreenSetSize = NULL;
|
||||
pScrPriv->rrCrtcSet = NULL;
|
||||
pScrPriv->rrCrtcSetGamma = NULL;
|
||||
#endif
|
||||
|
|
|
@ -174,7 +174,7 @@ typedef struct _rrScrPriv {
|
|||
#endif
|
||||
RRGetInfoProcPtr rrGetInfo;
|
||||
#if RANDR_12_INTERFACE
|
||||
RRScreenSetSizeProcPtr rrScreenSizeSet;
|
||||
RRScreenSetSizeProcPtr rrScreenSetSize;
|
||||
RRCrtcSetProcPtr rrCrtcSet;
|
||||
RRCrtcSetGammaProcPtr rrCrtcSetGamma;
|
||||
#endif
|
||||
|
@ -521,7 +521,7 @@ RRClientKnowsRates (ClientPtr pClient);
|
|||
RRModePtr
|
||||
RRModeGet (ScreenPtr pScreen,
|
||||
xRRModeInfo *modeInfo,
|
||||
char *name);
|
||||
const char *name);
|
||||
|
||||
/*
|
||||
* Destroy a mode.
|
||||
|
@ -555,7 +555,7 @@ ProcRRDeleteOutputMode (ClientPtr client);
|
|||
|
||||
RROutputPtr
|
||||
RROutputCreate (ScreenPtr pScreen,
|
||||
char *name,
|
||||
const char *name,
|
||||
int nameLength,
|
||||
void *devPrivate);
|
||||
|
||||
|
|
|
@ -94,13 +94,22 @@ RRCrtcNotify (RRCrtcPtr crtc,
|
|||
{
|
||||
RROutputPtr *outputs;
|
||||
|
||||
if (crtc->numOutputs)
|
||||
outputs = xrealloc (crtc->outputs,
|
||||
numOutputs * sizeof (RROutputPtr));
|
||||
if (numOutputs)
|
||||
{
|
||||
if (crtc->numOutputs)
|
||||
outputs = xrealloc (crtc->outputs,
|
||||
numOutputs * sizeof (RROutputPtr));
|
||||
else
|
||||
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return FALSE;
|
||||
{
|
||||
if (crtc->outputs)
|
||||
xfree (crtc->outputs);
|
||||
outputs = NULL;
|
||||
}
|
||||
crtc->outputs = outputs;
|
||||
}
|
||||
for (i = 0; i < numOutputs; i++)
|
||||
|
@ -300,9 +309,14 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
|
|||
|
||||
if (size == crtc->gammaSize)
|
||||
return TRUE;
|
||||
gamma = xalloc (size * 3 * sizeof (CARD16));
|
||||
if (!gamma)
|
||||
return FALSE;
|
||||
if (size)
|
||||
{
|
||||
gamma = xalloc (size * 3 * sizeof (CARD16));
|
||||
if (!gamma)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
gamma = NULL;
|
||||
if (crtc->gammaRed)
|
||||
xfree (crtc->gammaRed);
|
||||
crtc->gammaRed = gamma;
|
||||
|
@ -376,9 +390,14 @@ ProcRRGetCrtcInfo (ClientPtr client)
|
|||
rep.length = rep.nOutput + rep.nPossibleOutput;
|
||||
|
||||
extraLen = rep.length << 2;
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
if (extraLen)
|
||||
{
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
outputs = (RROutput *) extra;
|
||||
possible = (RROutput *) (outputs + rep.nOutput);
|
||||
|
@ -467,9 +486,14 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
|||
if (numOutputs == 0)
|
||||
return BadMatch;
|
||||
}
|
||||
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return BadAlloc;
|
||||
if (numOutputs)
|
||||
{
|
||||
outputs = xalloc (numOutputs * sizeof (RROutputPtr));
|
||||
if (!outputs)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
outputs = NULL;
|
||||
|
||||
outputIds = (RROutput *) (stuff + 1);
|
||||
for (i = 0; i < numOutputs; i++)
|
||||
|
@ -574,7 +598,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
|||
* for setting screen size. Else, assume the CrtcSet sets
|
||||
* the size along with the mode
|
||||
*/
|
||||
if (pScrPriv->rrScreenSizeSet)
|
||||
if (pScrPriv->rrScreenSetSize)
|
||||
{
|
||||
if (stuff->x + mode->mode.width > pScreen->width)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ RESTYPE RRModeType;
|
|||
RRModePtr
|
||||
RRModeGet (ScreenPtr pScreen,
|
||||
xRRModeInfo *modeInfo,
|
||||
char *name)
|
||||
const char *name)
|
||||
{
|
||||
rrScrPriv (pScreen);
|
||||
int i;
|
||||
|
|
|
@ -30,7 +30,7 @@ RESTYPE RROutputType;
|
|||
|
||||
RROutputPtr
|
||||
RROutputCreate (ScreenPtr pScreen,
|
||||
char *name,
|
||||
const char *name,
|
||||
int nameLength,
|
||||
void *devPrivate)
|
||||
{
|
||||
|
@ -89,9 +89,14 @@ RROutputSetClones (RROutputPtr output,
|
|||
{
|
||||
RROutputPtr *newClones;
|
||||
|
||||
newClones = xalloc (numClones * sizeof (RROutputPtr));
|
||||
if (!newClones)
|
||||
return FALSE;
|
||||
if (numClones)
|
||||
{
|
||||
newClones = xalloc (numClones * sizeof (RROutputPtr));
|
||||
if (!newClones)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
newClones = NULL;
|
||||
if (output->clones)
|
||||
xfree (output->clones);
|
||||
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
|
||||
|
@ -108,9 +113,14 @@ RROutputSetModes (RROutputPtr output,
|
|||
{
|
||||
RRModePtr *newModes;
|
||||
|
||||
newModes = xalloc (numModes * sizeof (RRModePtr));
|
||||
if (!newModes)
|
||||
return FALSE;
|
||||
if (numModes)
|
||||
{
|
||||
newModes = xalloc (numModes * sizeof (RRModePtr));
|
||||
if (!newModes)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
newModes = NULL;
|
||||
if (output->modes)
|
||||
xfree (output->modes);
|
||||
memcpy (newModes, modes, numModes * sizeof (RRModePtr));
|
||||
|
@ -127,9 +137,14 @@ RROutputSetCrtcs (RROutputPtr output,
|
|||
{
|
||||
RRCrtcPtr *newCrtcs;
|
||||
|
||||
newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr));
|
||||
if (!newCrtcs)
|
||||
return FALSE;
|
||||
if (numCrtcs)
|
||||
{
|
||||
newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr));
|
||||
if (!newCrtcs)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
newCrtcs = NULL;
|
||||
if (output->crtcs)
|
||||
xfree (output->crtcs);
|
||||
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
|
||||
|
@ -265,9 +280,14 @@ ProcRRGetOutputInfo (ClientPtr client)
|
|||
((rep.nameLength + 3) >> 2));
|
||||
|
||||
extraLen = rep.length << 2;
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
if (extraLen)
|
||||
{
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||
|
|
|
@ -187,9 +187,9 @@ RRScreenSizeSet (ScreenPtr pScreen,
|
|||
rrScrPriv(pScreen);
|
||||
|
||||
#if RANDR_12_INTERFACE
|
||||
if (pScrPriv->rrScreenSizeSet)
|
||||
if (pScrPriv->rrScreenSetSize)
|
||||
{
|
||||
return (*pScrPriv->rrScreenSizeSet) (pScreen,
|
||||
return (*pScrPriv->rrScreenSetSize) (pScreen,
|
||||
width, height,
|
||||
mmWidth, mmHeight);
|
||||
}
|
||||
|
@ -376,9 +376,14 @@ ProcRRGetScreenResources (ClientPtr client)
|
|||
((rep.nbytesNames + 3) >> 2));
|
||||
|
||||
extraLen = rep.length << 2;
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
if (extraLen)
|
||||
{
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
crtcs = (RRCrtc *) extra;
|
||||
outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
|
||||
|
@ -595,12 +600,18 @@ ProcRRGetScreenInfo (ClientPtr client)
|
|||
extraLen = (rep.nSizes * sizeof (xScreenSizes) +
|
||||
rep.nrateEnts * sizeof (CARD16));
|
||||
|
||||
extra = (CARD8 *) xalloc (extraLen);
|
||||
if (!extra)
|
||||
if (extraLen)
|
||||
{
|
||||
xfree (pData);
|
||||
return BadAlloc;
|
||||
extra = (CARD8 *) xalloc (extraLen);
|
||||
if (!extra)
|
||||
{
|
||||
xfree (pData);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
else
|
||||
extra = NULL;
|
||||
|
||||
/*
|
||||
* First comes the size information
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue