From 937c2615e6ab926d7b2cff2b38fae8f0600e6ba0 Mon Sep 17 00:00:00 2001 From: Joachim Henze Date: Sat, 17 Feb 2018 19:29:24 +0100 Subject: [PATCH] [0.4.8] [USP10] Apply unfinished patch to avoid CORE-14226 Thomas linked the patch in Wine Bug 44410 I tested it for some weeks without noticing any side-effects. It avoids text rendering regressions in some setups like UltraISO --- dll/win32/usp10/usp10.c | 20 ++++++++++++-------- dll/win32/usp10/usp10_internal.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dll/win32/usp10/usp10.c b/dll/win32/usp10/usp10.c index abc40fc891a..86efc89d702 100644 --- a/dll/win32/usp10/usp10.c +++ b/dll/win32/usp10/usp10.c @@ -830,19 +830,23 @@ static inline WORD set_cache_glyph(SCRIPT_CACHE *psc, WCHAR c, WORD glyph) return ((*block)[(c % 0x10000) & GLYPH_BLOCK_MASK] = glyph); } -static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc) +static inline BOOL get_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc, BOOL no_glyph_index) { static const ABC nil; - ABC *block = ((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT]; + ABC *block = no_glyph_index ? + ((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] : + ((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT]; if (!block || !memcmp(&block[glyph & GLYPH_BLOCK_MASK], &nil, sizeof(ABC))) return FALSE; memcpy(abc, &block[glyph & GLYPH_BLOCK_MASK], sizeof(ABC)); return TRUE; } -static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc) +static inline BOOL set_cache_glyph_widths(SCRIPT_CACHE *psc, WORD glyph, ABC *abc, BOOL no_glyph_index) { - ABC **block = &((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT]; + ABC **block = no_glyph_index ? + &((ScriptCache *)*psc)->widths[glyph >> GLYPH_BLOCK_SHIFT] : + &((ScriptCache *)*psc)->glyph_widths[glyph >> GLYPH_BLOCK_SHIFT]; if (!*block && !(*block = heap_alloc_zero(sizeof(ABC) * GLYPH_BLOCK_SIZE))) return FALSE; memcpy(&(*block)[glyph & GLYPH_BLOCK_MASK], abc, sizeof(ABC)); @@ -3413,7 +3417,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS { abc.abcA = abc.abcB = abc.abcC = 0; } - else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc)) + else if (!get_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex)) { BOOL ret; if (!hdc) return E_PENDING; @@ -3436,7 +3440,7 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS abc.abcB = width; abc.abcA = abc.abcC = 0; } - set_cache_glyph_widths(psc, pwGlyphs[i], &abc); + set_cache_glyph_widths(psc, pwGlyphs[i], &abc, psa->fNoGlyphIndex); } if (pABC) { @@ -3698,7 +3702,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB if (!abc) return E_INVALIDARG; if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr; - if (!get_cache_glyph_widths(psc, glyph, abc)) + if (!get_cache_glyph_widths(psc, glyph, abc, FALSE)) { if (!hdc) return E_PENDING; if ((get_cache_pitch_family(psc) & TMPF_TRUETYPE)) @@ -3712,7 +3716,7 @@ HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, AB abc->abcB = width; abc->abcA = abc->abcC = 0; } - set_cache_glyph_widths(psc, glyph, abc); + set_cache_glyph_widths(psc, glyph, abc, FALSE); } return S_OK; } diff --git a/dll/win32/usp10/usp10_internal.h b/dll/win32/usp10/usp10_internal.h index c0e28d542c0..63293144d9d 100644 --- a/dll/win32/usp10/usp10_internal.h +++ b/dll/win32/usp10/usp10_internal.h @@ -204,6 +204,7 @@ typedef struct { BOOL sfnt; CacheGlyphPage *page[NUM_PAGES]; ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE]; + ABC *glyph_widths[GLYPH_MAX / GLYPH_BLOCK_SIZE]; void *GSUB_Table; void *GDEF_Table; void *CMAP_Table;