Commit 0946c154 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

ole32: PropVariantClear should always reset contents of the passed in PROPVARIANT.

parent 7de7fc65
...@@ -2919,7 +2919,10 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */ ...@@ -2919,7 +2919,10 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */
hr = PROPVARIANT_ValidateType(pvar->vt); hr = PROPVARIANT_ValidateType(pvar->vt);
if (FAILED(hr)) if (FAILED(hr))
{
memset(pvar, 0, sizeof(*pvar));
return hr; return hr;
}
switch(pvar->vt) switch(pvar->vt)
{ {
...@@ -3006,12 +3009,14 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */ ...@@ -3006,12 +3009,14 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */
} }
} }
else else
{
WARN("Invalid/unsupported type %d\n", pvar->vt); WARN("Invalid/unsupported type %d\n", pvar->vt);
hr = STG_E_INVALIDPARAMETER;
}
} }
ZeroMemory(pvar, sizeof(*pvar)); memset(pvar, 0, sizeof(*pvar));
return hr;
return S_OK;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -187,9 +187,7 @@ static void test_validtypes(void) ...@@ -187,9 +187,7 @@ static void test_validtypes(void)
memset(&propvar, 0x55, sizeof(propvar)); memset(&propvar, 0x55, sizeof(propvar));
hr = PropVariantClear(&propvar); hr = PropVariantClear(&propvar);
ok(hr == STG_E_INVALIDPARAMETER, "expected STG_E_INVALIDPARAMETER, got %08x\n", hr); ok(hr == STG_E_INVALIDPARAMETER, "expected STG_E_INVALIDPARAMETER, got %08x\n", hr);
todo_wine
ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt); ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
todo_wine
ok(U(propvar).uhVal.QuadPart == 0, "expected 0, got %#x/%#x\n", ok(U(propvar).uhVal.QuadPart == 0, "expected 0, got %#x/%#x\n",
U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart); U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
...@@ -202,25 +200,16 @@ todo_wine ...@@ -202,25 +200,16 @@ todo_wine
vt = propvar.vt = i; vt = propvar.vt = i;
hr = PropVariantClear(&propvar); hr = PropVariantClear(&propvar);
expect(hr, vt); expect(hr, vt);
if (hr == S_OK) /* FIXME: Remove once Wine is fixed */ ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
else
todo_wine
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n", ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart); i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
memset(&propvar, 0x55, sizeof(propvar)); memset(&propvar, 0x55, sizeof(propvar));
U(propvar).pszVal = NULL; U(propvar).pszVal = NULL;
vt = propvar.vt = i | VT_ARRAY; vt = propvar.vt = i | VT_ARRAY;
hr = PropVariantClear(&propvar); hr = PropVariantClear(&propvar);
expect(hr, vt); expect(hr, vt);
if (hr == S_OK) /* FIXME: Remove once Wine is fixed */ ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
else
todo_wine
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n", ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart); i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
...@@ -229,11 +218,7 @@ todo_wine ...@@ -229,11 +218,7 @@ todo_wine
vt = propvar.vt = i | VT_VECTOR; vt = propvar.vt = i | VT_VECTOR;
hr = PropVariantClear(&propvar); hr = PropVariantClear(&propvar);
expect(hr, vt); expect(hr, vt);
if (hr == S_OK) /* FIXME: Remove once Wine is fixed */ ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
else
todo_wine
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n", ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart); i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
...@@ -242,11 +227,7 @@ todo_wine ...@@ -242,11 +227,7 @@ todo_wine
vt = propvar.vt = i | VT_BYREF; vt = propvar.vt = i | VT_BYREF;
hr = PropVariantClear(&propvar); hr = PropVariantClear(&propvar);
expect(hr, vt); expect(hr, vt);
if (hr == S_OK) /* FIXME: Remove once Wine is fixed */ ok(propvar.vt == 0, "expected 0, got %d\n", propvar.vt);
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
else
todo_wine
ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n", ok(U(propvar).uhVal.QuadPart == 0, "%u: expected 0, got %#x/%#x\n",
i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart); i, U(propvar).uhVal.u.LowPart, U(propvar).uhVal.u.HighPart);
} }
......
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