diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 32ed7123918..c4b8818df72 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 d773c666d01..a9a68028b24 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]);