[v2 PATCH 3/5] dwrite: Handle NULL path in CreateFontFileReference()

Nikolay Sivov nsivov at codeweavers.com
Wed Apr 20 02:50:59 CDT 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

v2: no changes

 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 fef11e6..4d5f43c 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 47f57d8..da12669 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 d5de80e..64e6a93 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);
 
-- 
2.8.0.rc3




More information about the wine-patches mailing list