From 827ac06d05c9f73d59af5e9b4340aaa5dc143713 Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Tue, 29 Mar 2011 18:22:50 +0300 Subject: [PATCH] render: fix memory leaks in ProcRenderCompositeGlyphs Signed-off-by: Tiago Vignatti Reviewed-by: Peter Hutterer Reviewed-by: Nicolas Peninguy Reviewed-by: Soren Sandmann --- render/render.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/render/render.c b/render/render.c index 85a43924a..7eaaa5741 100644 --- a/render/render.c +++ b/render/render.c @@ -1365,8 +1365,10 @@ ProcRenderCompositeGlyphs (ClientPtr client) else { listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec)); - if (!listsBase) - return BadAlloc; + if (!listsBase) { + rc = BadAlloc; + goto bail; + } } buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; @@ -1385,13 +1387,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) GlyphSetType, client, DixUseAccess); if (rc != Success) - { - if (glyphsBase != glyphsLocal) - free(glyphsBase); - if (listsBase != listsLocal) - free(listsBase); - return rc; - } + goto bail; } buffer += 4; } @@ -1429,8 +1425,10 @@ ProcRenderCompositeGlyphs (ClientPtr client) lists++; } } - if (buffer > end) - return BadLength; + if (buffer > end) { + rc = BadLength; + goto bail; + } CompositeGlyphs (stuff->op, pSrc, @@ -1441,13 +1439,14 @@ ProcRenderCompositeGlyphs (ClientPtr client) nlist, listsBase, glyphsBase); + rc = Success; +bail: if (glyphsBase != glyphsLocal) free(glyphsBase); if (listsBase != listsLocal) free(listsBase); - - return Success; + return rc; } static int