Nikolay Sivov : dwrite: Use temporary buffers for GetGlyphs().

Alexandre Julliard julliard at winehq.org
Tue May 26 17:17:06 CDT 2020


Module: wine
Branch: master
Commit: 76b1f3fd729bbfb823d2fccb85f6fd49e7e0e04c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=76b1f3fd729bbfb823d2fccb85f6fd49e7e0e04c

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue May 26 11:16:10 2020 +0300

dwrite: Use temporary buffers for GetGlyphs().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 786d68ac27..3754fe39a1 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 dd25c619c1..ce278e5499 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 77c5ba1f8a..b7b40d1211 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;
 }




More information about the wine-cvs mailing list