Marcus Meissner : usp10: Fixed some oom handling (Coverity).
Alexandre Julliard
julliard at winehq.org
Mon Oct 17 13:08:54 CDT 2011
Module: wine
Branch: master
Commit: 76702f33916f69af67352c9c3e8720c5e3b8d267
URL: http://source.winehq.org/git/wine.git/?a=commit;h=76702f33916f69af67352c9c3e8720c5e3b8d267
Author: Marcus Meissner <marcus at jet.franken.de>
Date: Sun Oct 16 12:38:24 2011 +0200
usp10: Fixed some oom handling (Coverity).
---
dlls/usp10/usp10.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 107f8cc..65d42e4 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -1029,6 +1029,8 @@ static BOOL requires_fallback(HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa,
return TRUE;
glyphs = heap_alloc(sizeof(WORD) * cChars);
+ if (!glyphs)
+ return FALSE;
if (ScriptGetCMap(hdc, psc, pwcInChars, cChars, 0, glyphs) != S_OK)
{
heap_free(glyphs);
@@ -1111,6 +1113,11 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
if (dwFlags & SSA_PASSWORD)
{
iString = heap_alloc(sizeof(WCHAR)*cString);
+ if (!iString)
+ {
+ hr = E_OUTOFMEMORY;
+ goto error;
+ }
for (i = 0; i < cString; i++)
iString[i] = *((const WCHAR *)pString);
pString = iString;
@@ -1133,6 +1140,9 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
}
if (hr != S_OK) goto error;
+ /* set back to out of memory for default goto error behaviour */
+ hr = E_OUTOFMEMORY;
+
if (dwFlags & SSA_BREAK)
{
if ((analysis->logattrs = heap_alloc(sizeof(SCRIPT_LOGATTR) * cString)))
@@ -1173,6 +1183,18 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString,
const WCHAR* pStr = (const WCHAR*)pString;
analysis->glyphs[i].fallbackFont = NULL;
+ if (!glyphs || !pwLogClust || !piAdvance || !psva || !pGoffset || !abc)
+ {
+ heap_free (glyphs);
+ heap_free (pwLogClust);
+ heap_free (piAdvance);
+ heap_free (psva);
+ heap_free (pGoffset);
+ heap_free (abc);
+ hr = E_OUTOFMEMORY;
+ goto error;
+ }
+
if ((dwFlags & SSA_FALLBACK) && requires_fallback(hdc, sc, &analysis->pItem[i].a, &pStr[analysis->pItem[i].iCharPos], cChar))
{
LOGFONTW lf;
More information about the wine-cvs
mailing list