diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-05-16 18:28:13 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-05-17 16:21:49 -0700 |
commit | 214ca6a7a2247544627e6dc7c8705811305ad007 (patch) | |
tree | 4b721fde06d705b7c8b9360cd371af1bf2616b1f /src/bitmap | |
parent | 7f8345aa6fb60a7fd7adf0095a2354fad1d8d5ef (diff) |
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 <unknown> 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(...).
<unknown> 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 <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'src/bitmap')
-rw-r--r-- | src/bitmap/bitscale.c | 11 |
1 files changed, 4 insertions, 7 deletions
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; } |