[PATCH 3/5] dwrite: Use temporary buffers for GetGlyphs().
Nikolay Sivov
nsivov at codeweavers.com
Tue May 26 03:16:10 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/dwrite/analyzer.c | 9 +++++++--
dlls/dwrite/dwrite_private.h | 1 +
dlls/dwrite/shape.c | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c
index 786d68ac278..3754fe39a19 100644
--- a/dlls/dwrite/analyzer.c
+++ b/dlls/dwrite/analyzer.c
@@ -1173,10 +1173,11 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
context.length = length;
context.is_rtl = is_rtl;
context.is_sideways = is_sideways;
- context.u.subst.glyphs = glyphs;
- context.u.subst.glyph_props = glyph_props;
+ context.u.subst.glyphs = heap_calloc(max_glyph_count, sizeof(*glyphs));
+ context.u.subst.glyph_props = heap_calloc(max_glyph_count, sizeof(*glyph_props));
context.u.subst.clustermap = clustermap;
context.u.subst.max_glyph_count = max_glyph_count;
+ context.u.subst.capacity = max_glyph_count;
context.u.subst.digits = digits;
context.language_tag = get_opentype_language(locale);
context.user_features.features = features;
@@ -1190,10 +1191,14 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
if (SUCCEEDED(hr))
{
*actual_glyph_count = context.glyph_count;
+ memcpy(glyphs, context.u.subst.glyphs, context.glyph_count * sizeof(*glyphs));
+ memcpy(glyph_props, context.u.subst.glyph_props, context.glyph_count * sizeof(*glyph_props));
hr = default_shaping_ops.set_text_glyphs_props(&context, clustermap, glyphs, *actual_glyph_count,
text_props, glyph_props);
}
+ heap_free(context.u.subst.glyph_props);
+ heap_free(context.u.subst.glyphs);
heap_free(context.glyph_infos);
return hr;
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index dd25c619c11..ce278e54992 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -491,6 +491,7 @@ struct scriptshaping_context
DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props;
UINT16 *clustermap;
unsigned int max_glyph_count;
+ unsigned int capacity;
const WCHAR *digits;
} subst;
} u;
diff --git a/dlls/dwrite/shape.c b/dlls/dwrite/shape.c
index 77c5ba1f8a2..b7b40d1211d 100644
--- a/dlls/dwrite/shape.c
+++ b/dlls/dwrite/shape.c
@@ -400,5 +400,5 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i
heap_free(features.features);
- return S_OK;
+ return (context->glyph_count <= context->u.subst.max_glyph_count) ? S_OK : E_NOT_SUFFICIENT_BUFFER;
}
--
2.26.2
More information about the wine-devel
mailing list