usp10: fix memory leaks
Pierre Schweitzer
pierre at reactos.org
Tue Dec 6 16:29:41 CST 2011
-------------- next part --------------
>From c371e58583117425bc051f7f505a6e502b306b72 Mon Sep 17 00:00:00 2001
From: Pierre Schweitzer <pierre at reactos.org>
Date: Tue, 6 Dec 2011 21:54:25 +0100
Subject: Fix memory leaks
---
dlls/usp10/usp10.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index fdd8750..1506bd5 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -1439,7 +1439,10 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
{
int tab_x = 0;
if (!(analysis->glyphs = heap_alloc_zero(sizeof(StringGlyphs) * analysis->numItems)))
+ {
+ heap_free(BidiLevel);
goto error;
+ }
for (i = 0; i < analysis->numItems; i++)
{
@@ -2422,8 +2425,16 @@ HRESULT WINAPI ScriptShapeOpenType( HDC hdc, SCRIPT_CACHE *psc,
if (!(pwOutGlyphs[i] = get_cache_glyph(psc, chInput)))
{
WORD glyph;
- if (!hdc) return E_PENDING;
- if (GetGlyphIndicesW(hdc, &chInput, 1, &glyph, 0) == GDI_ERROR) return S_FALSE;
+ if (!hdc)
+ {
+ heap_free(rChars);
+ return E_PENDING;
+ }
+ if (GetGlyphIndicesW(hdc, &chInput, 1, &glyph, 0) == GDI_ERROR)
+ {
+ heap_free(rChars);
+ return S_FALSE;
+ }
pwOutGlyphs[i] = set_cache_glyph(psc, chInput, glyph);
}
rChars[i] = chInput;
@@ -2487,7 +2498,11 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars,
charProps = heap_alloc_zero(sizeof(SCRIPT_CHARPROP)*cChars);
if (!charProps) return E_OUTOFMEMORY;
glyphProps = heap_alloc_zero(sizeof(SCRIPT_GLYPHPROP)*cMaxGlyphs);
- if (!glyphProps) return E_OUTOFMEMORY;
+ if (!glyphProps)
+ {
+ heap_free(charProps);
+ return E_OUTOFMEMORY;
+ }
hr = ScriptShapeOpenType(hdc, psc, psa, scriptInformation[psa->eScript].scriptTag, 0, NULL, NULL, 0, pwcChars, cChars, cMaxGlyphs, pwLogClust, charProps, pwOutGlyphs, glyphProps, pcGlyphs);
--
1.7.4.1
More information about the wine-patches
mailing list