diff options
Diffstat (limited to 'dix/colormap.c')
-rw-r--r-- | dix/colormap.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/dix/colormap.c b/dix/colormap.c index b27b8bc67..c4c8c8bfe 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -63,9 +63,10 @@ SOFTWARE. #include "scrnintstr.h" #include "resource.h" #include "windowstr.h" +#include "privates.h" +#include "xace.h" extern XID clientErrorValue; -extern int colormapPrivateCount; static Pixel FindBestPixel( EntryPtr /*pentFirst*/, @@ -386,31 +387,25 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->numPixelsBlue[client] = size; } } - if (!AddResource(mid, RT_COLORMAP, (pointer)pmap)) - return (BadAlloc); - /* If the device wants a chance to initialize the colormap in any way, - * this is it. In specific, if this is a Static colormap, this is the - * time to fill in the colormap's values */ + pmap->devPrivates = NULL; pmap->flags |= BeingCreated; + if (!AddResource(mid, RT_COLORMAP, (pointer)pmap)) + return (BadAlloc); - /* - * Allocate the array of devPrivate's for this colormap. + /* + * Security creation/labeling check */ - - if (colormapPrivateCount == 0) - pmap->devPrivates = NULL; - else - { - pmap->devPrivates = (DevUnion *) xcalloc ( - sizeof(DevUnion), colormapPrivateCount); - if (!pmap->devPrivates) - { - FreeResource (mid, RT_NONE); - return BadAlloc; - } + i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP, + pmap, RT_NONE, NULL, DixCreateAccess); + if (i != Success) { + FreeResource(mid, RT_NONE); + return i; } + /* If the device wants a chance to initialize the colormap in any way, + * this is it. In specific, if this is a Static colormap, this is the + * time to fill in the colormap's values */ if (!(*pScreen->CreateColormap)(pmap)) { FreeResource (mid, RT_NONE); @@ -474,9 +469,7 @@ FreeColormap (pointer value, XID mid) } } - if (pmap->devPrivates) - xfree(pmap->devPrivates); - + dixFreePrivates(pmap->devPrivates); xfree(pmap); return(Success); } |