Alloc/free drawables array for each ProcPanoramiXShmGetImage call.

Updates my previous patch, b422b532f3.
keithp recommended against allocating the drawables array globally, but my
updated patch with that fixed isn't the patch that landed.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Jamey Sharp 2009-10-28 16:35:28 -07:00 committed by Keith Packard
parent 757c11630d
commit 25979c46b4

View File

@ -141,7 +141,6 @@ int BadShmSegCode;
RESTYPE ShmSegType; RESTYPE ShmSegType;
static ShmDescPtr Shmsegs; static ShmDescPtr Shmsegs;
static Bool sharedPixmaps; static Bool sharedPixmaps;
static DrawablePtr *drawables;
static int shmScrPrivateKeyIndex; static int shmScrPrivateKeyIndex;
static DevPrivateKey shmScrPrivateKey = &shmScrPrivateKeyIndex; static DevPrivateKey shmScrPrivateKey = &shmScrPrivateKeyIndex;
static int shmPixmapPrivateIndex; static int shmPixmapPrivateIndex;
@ -259,13 +258,6 @@ ShmExtensionInit(INITARGS)
} }
#endif #endif
drawables = xcalloc(screenInfo.numScreens, sizeof(DrawablePtr));
if (!drawables)
{
ErrorF("MIT-SHM extension disabled: no memory for per-screen drawables\n");
return;
}
sharedPixmaps = xFalse; sharedPixmaps = xFalse;
{ {
sharedPixmaps = xTrue; sharedPixmaps = xTrue;
@ -618,6 +610,7 @@ static int
ProcPanoramiXShmGetImage(ClientPtr client) ProcPanoramiXShmGetImage(ClientPtr client)
{ {
PanoramiXRes *draw; PanoramiXRes *draw;
DrawablePtr *drawables;
DrawablePtr pDraw; DrawablePtr pDraw;
xShmGetImageReply xgi; xShmGetImageReply xgi;
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
@ -678,12 +671,19 @@ ProcPanoramiXShmGetImage(ClientPtr client)
return(BadMatch); return(BadMatch);
} }
drawables = xcalloc(PanoramiXNumScreens, sizeof(DrawablePtr));
if(!drawables)
return(BadAlloc);
drawables[0] = pDraw; drawables[0] = pDraw;
for(i = 1; i < PanoramiXNumScreens; i++) { for(i = 1; i < PanoramiXNumScreens; i++) {
rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0,
DixReadAccess); DixReadAccess);
if (rc != Success) if (rc != Success)
{
xfree(drawables);
return rc; return rc;
}
} }
xgi.visual = wVisual(((WindowPtr)pDraw)); xgi.visual = wVisual(((WindowPtr)pDraw));
@ -722,6 +722,7 @@ ProcPanoramiXShmGetImage(ClientPtr client)
} }
} }
} }
xfree(drawables);
if (client->swapped) { if (client->swapped) {
int n; int n;