From 214ca6a7a2247544627e6dc7c8705811305ad007 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 16 May 2011 18:28:13 -0700 Subject: Fix memory leak in allocation failure path of BitmapOpenScalable() Go ahead and fill in the font->info pointers so that bitmapUnloadScalable() will free the bits that were allocated, even if some were not. Error: Memory leak (CWE 401) Memory leak of pointer allocated with ComputeScaledProperties(...) at line 1629 of /export/alanc/X.Org/git/lib/libXfont/src/bitmap/bitscale.c in function 'BitmapOpenScalable'. pointer allocated at line 1616 with ComputeScaledProperties(...). leaks when props != 0 at line 1623. [ This bug was found by the Parfait 0.3.7 bug checking tool. For more information see http://labs.oracle.com/projects/parfait/ ] Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- src/bitmap/bitscale.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c index cf16bff..50818c6 100644 --- a/src/bitmap/bitscale.c +++ b/src/bitmap/bitscale.c @@ -1620,19 +1620,16 @@ BitmapOpenScalable (FontPathElementPtr fpe, if (!sourceFont->refcnt) FontFileCloseFont((FontPathElementPtr) 0, sourceFont); + font->info.props = props; + font->info.nprops = propCount; + font->info.isStringProp = isStringProp; + if (propCount && (!props || !isStringProp)) { - font->info.nprops = 0; - font->info.props = (FontPropPtr)0; - font->info.isStringProp = (char *)0; bitmapUnloadScalable(font); return AllocError; } - font->info.props = props; - font->info.nprops = propCount; - font->info.isStringProp = isStringProp; - *pFont = font; return Successful; } -- cgit v1.2.3