Aric Stewart : usp10: Fix memory leak when a font has 0 languages, scripts or features.
Alexandre Julliard
julliard at winehq.org
Fri Feb 8 14:13:46 CST 2013
Module: wine
Branch: master
Commit: 237ed21737de24fb7f0a508eb87b3c7937164258
URL: http://source.winehq.org/git/wine.git/?a=commit;h=237ed21737de24fb7f0a508eb87b3c7937164258
Author: Aric Stewart <aric at codeweavers.com>
Date: Fri Feb 8 09:46:08 2013 -0600
usp10: Fix memory leak when a font has 0 languages, scripts or features.
Based on original fix proposded by Wojciech Pyczak.
---
dlls/usp10/opentype.c | 22 ++++++++++++++++++----
dlls/usp10/usp10_internal.h | 3 +++
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/dlls/usp10/opentype.c b/dlls/usp10/opentype.c
index 85eacf9..a48a607 100644
--- a/dlls/usp10/opentype.c
+++ b/dlls/usp10/opentype.c
@@ -1898,6 +1898,9 @@ static void GPOS_expand_script_cache(ScriptCache *psc)
script = (const OT_ScriptList*)((const BYTE*)header + GET_BE_WORD(header->ScriptList));
count = GET_BE_WORD(script->ScriptCount);
+ if (!count)
+ return;
+
if (!psc->script_count)
{
psc->script_count = count;
@@ -1941,10 +1944,11 @@ static void GPOS_expand_script_cache(ScriptCache *psc)
static void _initialize_script_cache(ScriptCache *psc)
{
- if (!psc->script_count)
+ if (!psc->scripts_initialized)
{
GSUB_initialize_script_cache(psc);
GPOS_expand_script_cache(psc);
+ psc->scripts_initialized = TRUE;
}
}
@@ -2029,6 +2033,10 @@ static void GPOS_expand_language_cache(LoadedScript *script)
count = GET_BE_WORD(table->LangSysCount);
TRACE("Deflang %p, LangCount %i\n",script->default_language.gpos_table, count);
+
+ if (!count)
+ return;
+
if (!script->language_count)
{
int i;
@@ -2072,10 +2080,11 @@ static void GPOS_expand_language_cache(LoadedScript *script)
static void _initialize_language_cache(LoadedScript *script)
{
- if (!script->language_count)
+ if (!script->languages_initialized)
{
GSUB_initialize_language_cache(script);
GPOS_expand_language_cache(script);
+ script->languages_initialized = TRUE;
}
}
@@ -2194,6 +2203,10 @@ static void GPOS_expand_feature_cache(LPCVOID table, LoadedLanguage *language)
feature_list = (const OT_FeatureList*)((const BYTE*)header + GET_BE_WORD(header->FeatureList));
TRACE("%i features\n",count);
+
+ if (!count)
+ return;
+
if (!language->feature_count)
{
language->feature_count = count;
@@ -2219,7 +2232,7 @@ static void GPOS_expand_feature_cache(LPCVOID table, LoadedLanguage *language)
}
}
}
- else if (count)
+ else
{
language->features = HeapReAlloc(GetProcessHeap(),0,language->features, sizeof(LoadedFeature)*(language->feature_count + count));
@@ -2245,10 +2258,11 @@ static void GPOS_expand_feature_cache(LPCVOID table, LoadedLanguage *language)
static void _initialize_feature_cache(ScriptCache *psc, LoadedLanguage *language)
{
- if (!language->feature_count)
+ if (!language->features_initialized)
{
GSUB_initialize_feature_cache(psc->GSUB_Table, language);
GPOS_expand_feature_cache(psc->GPOS_Table, language);
+ language->features_initialized = TRUE;
}
}
diff --git a/dlls/usp10/usp10_internal.h b/dlls/usp10/usp10_internal.h
index 3ada1c4..77bb20d 100644
--- a/dlls/usp10/usp10_internal.h
+++ b/dlls/usp10/usp10_internal.h
@@ -144,6 +144,7 @@ typedef struct {
OPENTYPE_TAG tag;
LPCVOID gsub_table;
LPCVOID gpos_table;
+ BOOL features_initialized;
INT feature_count;
LoadedFeature *features;
} LoadedLanguage;
@@ -153,6 +154,7 @@ typedef struct {
LPCVOID gsub_table;
LPCVOID gpos_table;
LoadedLanguage default_language;
+ BOOL languages_initialized;
INT language_count;
LoadedLanguage *languages;
} LoadedScript;
@@ -174,6 +176,7 @@ typedef struct {
LPVOID CMAP_Table;
LPVOID CMAP_format12_Table;
LPVOID GPOS_Table;
+ BOOL scripts_initialized;
INT script_count;
LoadedScript *scripts;
More information about the wine-cvs
mailing list