[PATCH] usp10: Fixed some oom handling (Coverity)
Marcus Meissner
marcus at jet.franken.de
Sun Oct 16 05:38:24 CDT 2011
Hi,
Some heap_allocs missed checks in here. (CID 5344)
Also some goto error cases were done with hr = S_OK as hr was set
to S_OK inbetween. (spotted by Marcus eyes)
Ciao, Marcus
---
dlls/usp10/usp10.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 107f8cc..8ac3c0b 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,10 @@ 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,14 +1139,16 @@ 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)))
{
for (i = 0; i < analysis->numItems; i++)
ScriptBreak(&((LPWSTR)pString)[analysis->pItem[i].iCharPos], analysis->pItem[i+1].iCharPos - analysis->pItem[i].iCharPos, &analysis->pItem[i].a, &analysis->logattrs[analysis->pItem[i].iCharPos]);
- }
- else
+ } else
goto error;
}
@@ -1173,6 +1181,17 @@ 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;
--
1.7.3.4
More information about the wine-patches
mailing list