Commit eb750f8b authored by Alan Coopersmith's avatar Alan Coopersmith
Browse files

Check for failures from CreateNewResourceType



Make sure to check return value before setting bitmask flags.
For most calls, just fails to init the extension.   Since Xinput
already calls FatalError() on initialization failure, so does
failure to allocate Xinput's resource type.
Signed-off-by: default avatarAlan Coopersmith <alan.coopersmith@sun.com>
Reviewed-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 1df4bd60
......@@ -467,7 +467,9 @@ MultibufferExtensionInit()
* create the resource types
*/
MultibufferDrawableResType =
CreateNewResourceType(MultibufferDrawableDelete)|RC_DRAWABLE;
CreateNewResourceType(MultibufferDrawableDelete);
if (MultiBufferDrawableResType)
MultibufferDrawableResType |= RC_DRAWABLE;
MultibufferResType = CreateNewResourceType(MultibufferDelete);
MultibuffersResType = CreateNewResourceType(MultibuffersDelete);
OtherClientResType = CreateNewResourceType(OtherClientDelete);
......
......@@ -503,15 +503,19 @@ void PanoramiXExtensionInit(int argc, char *argv[])
}
XRC_DRAWABLE = CreateNewResourceClass();
XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource) |
XRC_DRAWABLE;
XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource) |
XRC_DRAWABLE;
XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource);
if (XRT_WINDOW)
XRT_WINDOW |= XRC_DRAWABLE;
XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource);
if (XRT_PIXMAP)
XRT_PIXMAP |= XRC_DRAWABLE;
XRT_GC = CreateNewResourceType(XineramaDeleteResource);
XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource);
panoramiXGeneration = serverGeneration;
success = TRUE;
if (XRT_WINDOW && XRT_PIXMAP && XRT_GC && XRT_COLORMAP) {
panoramiXGeneration = serverGeneration;
success = TRUE;
}
}
if (!success) {
......
......@@ -2113,8 +2113,12 @@ SyncExtensionInit(void)
RTCounter = CreateNewResourceType(FreeCounter);
}
RTAlarm = CreateNewResourceType(FreeAlarm);
RTAwait = CreateNewResourceType(FreeAwait)|RC_NEVERRETAIN;
RTAlarmClient = CreateNewResourceType(FreeAlarmClient)|RC_NEVERRETAIN;
RTAwait = CreateNewResourceType(FreeAwait);
if (RTAwait)
RTAwait |= RC_NEVERRETAIN;
RTAlarmClient = CreateNewResourceType(FreeAlarmClient);
if (RTAlarmClient)
RTAlarmClient |= RC_NEVERRETAIN;
if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 ||
RTAlarmClient == 0 ||
......
......@@ -1865,8 +1865,8 @@ void XineramifyXv(void)
XvXRTPort = CreateNewResourceType(XineramaDeleteResource);
if(!xvsp0) return;
if (!xvsp0 || !XvXRTPort) return;
for(i = 0; i < xvsp0->nAdaptors; i++) {
refAdapt = xvsp0->pAdaptors + i;
......
......@@ -1270,6 +1270,8 @@ XInputExtensionInit(void)
XIVersion = thisversion;
MakeDeviceTypeAtoms();
RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
if (!RT_INPUTCLIENT)
FatalError("Failed to add resource type for XI.\n");
RegisterResourceName(RT_INPUTCLIENT, "INPUTCLIENT");
FixExtensionEvents(extEntry);
ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch;
......
......@@ -1573,9 +1573,16 @@ DbeExtensionInit(void)
/* Create the resource types. */
dbeDrawableResType =
CreateNewResourceType(DbeDrawableDelete) | RC_DRAWABLE;
CreateNewResourceType(DbeDrawableDelete);
if (!dbeDrawableResType)
return;
dbeDrawableResType |= RC_DRAWABLE;
dbeWindowPrivResType =
CreateNewResourceType(DbeWindowPrivDelete);
if (!dbeWindowPrivResType)
return;
if (!dixRegisterPrivateOffset(dbeDrawableResType,
offsetof(PixmapRec, devPrivates)))
return;
......
......@@ -347,6 +347,9 @@ void GlxExtensionInit(void)
__glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
__glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone);
if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes)
return;
RegisterResourceName(__glXContextRes, "GLXContext");
RegisterResourceName(__glXDrawableRes, "GLXDrawable");
RegisterResourceName(__glXSwapBarrierRes, "GLXSwapBarrier");
......
......@@ -299,6 +299,10 @@ void GlxExtensionInit(void)
__glXWindowRes = CreateNewResourceType((DeleteType)WindowGone);
__glXPbufferRes = CreateNewResourceType((DeleteType)PbufferGone);
if (!__glXContextRes || !__glXClientRes || !__glXPixmapRes ||
!__glXWindowRes || !__glXPbufferRes)
return;
/*
** Add extension to server extensions.
*/
......
......@@ -141,6 +141,10 @@ ephyrDRIExtensionInit (ScreenPtr a_screen)
#ifdef XF86DRI_EVENTS
EventType = CreateNewResourceType (XF86DRIFreeEvents);
if (!EventType) {
EPHYR_LOG_ERROR ("failed to register DRI event resource type\n") ;
goto out ;
}
#endif
if ((extEntry = AddExtension(XF86DRINAME,
......
......@@ -792,6 +792,9 @@ DRIExtensionInit(void)
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete);
if (!DRIDrawablePrivResType || !DRIContextPrivResType)
return FALSE;
RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
return TRUE;
......
......@@ -416,6 +416,11 @@ static int DRI2DrawableGone(pointer p, XID id)
static void
DRI2ExtensionInit(void)
{
dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone);
if (!dri2DrawableRes)
return;
dri2Extension = AddExtension(DRI2_NAME,
DRI2NumberEvents,
DRI2NumberErrors,
......@@ -424,7 +429,6 @@ DRI2ExtensionInit(void)
NULL,
StandardMinorOpcode);
dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone);
}
extern Bool noDRI2Extension;
......
......@@ -279,7 +279,7 @@ DRIExtensionInit(void)
{
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
return TRUE;
return (DRIDrawablePrivResType != 0);
}
void
......
......@@ -1095,6 +1095,6 @@ XFixesCursorInit (void)
}
}
return CursorClientType && CursorWindowType;
return CursorClientType && CursorHideCountType && CursorWindowType;
}
......@@ -64,7 +64,8 @@ Bool
XFixesRegionInit (void)
{
RegionResType = CreateNewResourceType(RegionResFree);
return TRUE;
return (RegionResType != 0);
}
int
......
......@@ -6704,6 +6704,10 @@ XkbExtensionInit(void)
{
ExtensionEntry *extEntry;
RT_XKBCLIENT = CreateNewResourceType(XkbClientGone);
if (!RT_XKBCLIENT)
return;
if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors,
ProcXkbDispatch, SProcXkbDispatch,
NULL, StandardMinorOpcode))) {
......@@ -6711,7 +6715,6 @@ XkbExtensionInit(void)
XkbEventBase = (unsigned char)extEntry->eventBase;
XkbErrorBase = (unsigned char)extEntry->errorBase;
XkbKeyboardErrorCode = XkbErrorBase+XkbKeyboard;
RT_XKBCLIENT = CreateNewResourceType(XkbClientGone);
}
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment