diff --git a/dix/colormap.c b/dix/colormap.c index c21623cd1..47c6c51e3 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -398,9 +398,8 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->devPrivates = NULL; else { - pmap->devPrivates = (DevUnion *) xalloc ( - colormapPrivateCount * sizeof(DevUnion)); - + pmap->devPrivates = (DevUnion *) xcalloc ( + sizeof(DevUnion), colormapPrivateCount); if (!pmap->devPrivates) { FreeResource (mid, RT_NONE); diff --git a/dix/privates.c b/dix/privates.c index 933810517..1e04a7b22 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -347,10 +347,13 @@ AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc) { privs = (DevUnion *) xrealloc (pColormap->devPrivates, colormapPrivateCount * sizeof(DevUnion)); - + if (!privs) { + colormapPrivateCount--; + return -1; + } + bzero(&privs[index], sizeof(DevUnion)); pColormap->devPrivates = privs; - - if (!privs || !(*initPrivFunc)(pColormap,index)) + if (!(*initPrivFunc)(pColormap,index)) { colormapPrivateCount--; return -1;