Commit 5a3b87a0 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

ole32: Avoid null pointer dereferences in CoGetTreatAsClass.

parent 4c917e95
...@@ -3825,6 +3825,10 @@ HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID clsidNew) ...@@ -3825,6 +3825,10 @@ HRESULT WINAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID clsidNew)
LONG len = sizeof(szClsidNew); LONG len = sizeof(szClsidNew);
TRACE("(%s,%p)\n", debugstr_guid(clsidOld), clsidNew); TRACE("(%s,%p)\n", debugstr_guid(clsidOld), clsidNew);
if (!clsidOld || !clsidNew)
return E_INVALIDARG;
*clsidNew = *clsidOld; /* copy over old value */ *clsidNew = *clsidOld; /* copy over old value */
res = COM_OpenKeyForCLSID(clsidOld, wszTreatAs, KEY_READ, &hkey); res = COM_OpenKeyForCLSID(clsidOld, wszTreatAs, KEY_READ, &hkey);
......
...@@ -2176,10 +2176,18 @@ static void test_TreatAsClass(void) ...@@ -2176,10 +2176,18 @@ static void test_TreatAsClass(void)
win_skip("CoGetTreatAsClass not present\n"); win_skip("CoGetTreatAsClass not present\n");
return; return;
} }
hr = pCoGetTreatAsClass(&deadbeef,&out); hr = pCoGetTreatAsClass(&deadbeef,&out);
ok (hr == S_FALSE, "expected S_FALSE got %x\n",hr); ok (hr == S_FALSE, "expected S_FALSE got %x\n",hr);
ok (IsEqualGUID(&out,&deadbeef), "expected to get same clsid back\n"); 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); lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &clsidkey);
ok(!lr, "Couldn't open CLSID key, error %d\n", lr); ok(!lr, "Couldn't open CLSID key, error %d\n", lr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment