Alex Henrie : ole32: Avoid null pointer dereferences in CoGetTreatAsClass.

Alexandre Julliard julliard at winehq.org
Thu Jul 6 16:25:17 CDT 2017


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

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Wed Jul  5 23:01:22 2017 -0600

ole32: Avoid null pointer dereferences in CoGetTreatAsClass.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/compobj.c       | 4 ++++
 dlls/ole32/tests/compobj.c | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 1ce9cec..6024448 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -3825,6 +3825,10 @@ HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID clsidNew)
     LONG len = sizeof(szClsidNew);
 
     TRACE("(%s,%p)\n", debugstr_guid(clsidOld), clsidNew);
+
+    if (!clsidOld || !clsidNew)
+        return E_INVALIDARG;
+
     *clsidNew = *clsidOld; /* copy over old value */
 
     res = COM_OpenKeyForCLSID(clsidOld, wszTreatAs, KEY_READ, &hkey);
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index e585a46..feb1d72 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -2176,10 +2176,18 @@ static void test_TreatAsClass(void)
         win_skip("CoGetTreatAsClass not present\n");
         return;
     }
+
     hr = pCoGetTreatAsClass(&deadbeef,&out);
     ok (hr == S_FALSE, "expected S_FALSE got %x\n",hr);
     ok (IsEqualGUID(&out,&deadbeef), "expected to get same clsid back\n");
 
+    hr = pCoGetTreatAsClass(NULL, &out);
+    ok(hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr);
+    ok(IsEqualGUID(&out, &deadbeef), "expected no change to the clsid\n");
+
+    hr = pCoGetTreatAsClass(&deadbeef, NULL);
+    ok(hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr);
+
     lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &clsidkey);
     ok(!lr, "Couldn't open CLSID key, error %d\n", lr);
 




More information about the wine-cvs mailing list