Nikolay Sivov : dwrite: Fix invalid parameter handling in GetGlyphIndices( ).

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 16 10:34:23 CDT 2015


Module: wine
Branch: master
Commit: 2933e8666f77cf92d4458514d345abb9851a95f5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2933e8666f77cf92d4458514d345abb9851a95f5

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Mar 13 21:57:50 2015 +0300

dwrite: Fix invalid parameter handling in GetGlyphIndices().

---

 dlls/dwrite/font.c       |  8 ++++++++
 dlls/dwrite/tests/font.c | 23 ++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index 32ed712..c4b8818 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -392,6 +392,14 @@ static HRESULT WINAPI dwritefontface_GetGlyphIndices(IDWriteFontFace2 *iface, UI
 
     TRACE("(%p)->(%p %u %p)\n", This, codepoints, count, glyph_indices);
 
+    if (!glyph_indices)
+        return E_INVALIDARG;
+
+    if (!codepoints) {
+        memset(glyph_indices, 0, count*sizeof(UINT16));
+        return E_INVALIDARG;
+    }
+
     for (i = 0; i < count; i++)
         glyph_indices[i] = freetype_get_glyphindex(iface, codepoints[i]);
 
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index d773c66..a9a6802 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -1779,7 +1779,7 @@ static void test_CreateCustomFontFileReference(void)
     HRESULT hr;
     HRSRC fontrsrc;
     UINT32 codePoints[1] = {0xa8};
-    UINT16 indices[1];
+    UINT16 indices[2];
 
     factory = create_factory();
     factory2 = create_factory();
@@ -1876,6 +1876,27 @@ if (face2)
     IDWriteFontFace_Release(face2);
     IDWriteFontFile_Release(file2);
 
+    hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 0, NULL);
+    ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
+
+    hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 0, NULL);
+    ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
+
+    hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 0, indices);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 0, indices);
+    ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "got 0x%08x\n", hr);
+
+    indices[0] = indices[1] = 11;
+    hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 1, indices);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+    ok(indices[0] == 0, "got index %i\n", indices[0]);
+    ok(indices[1] == 11, "got index %i\n", indices[1]);
+
+if (0) /* crashes on native */
+    hr = IDWriteFontFace_GetGlyphIndices(face, NULL, 1, NULL);
+
     hr = IDWriteFontFace_GetGlyphIndices(face, codePoints, 1, indices);
     ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(indices[0] == 6, "got index %i\n", indices[0]);




More information about the wine-cvs mailing list