render: fix memory leaks in ProcRenderCompositeGlyphs

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
Reviewed-by: Soren Sandmann <ssp@redhat.com>
This commit is contained in:
Tiago Vignatti 2011-03-29 18:22:50 +03:00
parent 45b6667b65
commit bc61787a20

View File

@ -1372,8 +1372,10 @@ ProcRenderCompositeGlyphs (ClientPtr client)
else else
{ {
listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec)); listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec));
if (!listsBase) if (!listsBase) {
return BadAlloc; rc = BadAlloc;
goto bail;
}
} }
buffer = (CARD8 *) (stuff + 1); buffer = (CARD8 *) (stuff + 1);
glyphs = glyphsBase; glyphs = glyphsBase;
@ -1392,13 +1394,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
GlyphSetType, client, GlyphSetType, client,
DixUseAccess); DixUseAccess);
if (rc != Success) if (rc != Success)
{ goto bail;
if (glyphsBase != glyphsLocal)
free(glyphsBase);
if (listsBase != listsLocal)
free(listsBase);
return rc;
}
} }
buffer += 4; buffer += 4;
} }
@ -1436,8 +1432,10 @@ ProcRenderCompositeGlyphs (ClientPtr client)
lists++; lists++;
} }
} }
if (buffer > end) if (buffer > end) {
return BadLength; rc = BadLength;
goto bail;
}
CompositeGlyphs (stuff->op, CompositeGlyphs (stuff->op,
pSrc, pSrc,
@ -1448,13 +1446,14 @@ ProcRenderCompositeGlyphs (ClientPtr client)
nlist, nlist,
listsBase, listsBase,
glyphsBase); glyphsBase);
rc = Success;
bail:
if (glyphsBase != glyphsLocal) if (glyphsBase != glyphsLocal)
free(glyphsBase); free(glyphsBase);
if (listsBase != listsLocal) if (listsBase != listsLocal)
free(listsBase); free(listsBase);
return rc;
return Success;
} }
static int static int