From af18a098628fb60d3b296a689183c5a97e4afe1f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 20 Apr 2016 10:50:59 +0300 Subject: [PATCH] dwrite: Handle NULL path in CreateFontFileReference(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/font.c | 3 +++ dlls/dwrite/main.c | 2 ++ dlls/dwrite/tests/font.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index fef11e615bd..4d5f43c0f50 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -4399,6 +4399,9 @@ HRESULT get_local_refkey(const WCHAR *path, const FILETIME *writetime, void **ke { struct local_refkey *refkey; + if (!path) + return E_INVALIDARG; + *size = FIELD_OFFSET(struct local_refkey, name) + (strlenW(path)+1)*sizeof(WCHAR); *key = NULL; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 47f57d8c37b..da12669b222 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -778,6 +778,8 @@ static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory3 *ifa TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(path), writetime, font_file); + *font_file = NULL; + if (!This->localfontfileloader) { hr = create_localfontfileloader(&This->localfontfileloader); diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index d5de80e3a21..64e6a93d03f 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -2599,6 +2599,11 @@ static void test_CreateFontFileReference(void) path = create_testfontfile(test_fontfile); factory = create_factory(); + ffile = (void*)0xdeadbeef; + hr = IDWriteFactory_CreateFontFileReference(factory, NULL, NULL, &ffile); + ok(hr == E_INVALIDARG, "got 0x%08x\n",hr); + ok(ffile == NULL, "got %p\n", ffile); + hr = IDWriteFactory_CreateFontFileReference(factory, path, NULL, &ffile); ok(hr == S_OK, "got 0x%08x\n",hr);