From: Kevin Puetz PuetzKevinA@JohnDeere.com
VariantCopy was using the wrong allocator; VariantClear simply leaked --- dlls/oleaut32/tests/vartest.c | 8 ++++---- dlls/oleaut32/variant.c | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 3cf37290487..efbc93ba756 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1037,7 +1037,7 @@ static void test_VariantClear(void) hres = VariantClear(&v); ok(hres == S_OK, "ret %08lx\n", hres); ok(V_RECORD(&v) == (void*)0xdeadbeef, "got %p\n",V_RECORD(&v)); - todo_wine ok(!malloc_spy.validptr, "%p not freed\n",malloc_spy.validptr); + ok(!malloc_spy.validptr, "%p not freed\n",malloc_spy.validptr); ok(recinfo->recordclear == 1, "got %d\n", recinfo->recordclear); ok(recinfo->ref == 1, "got %ld\n", recinfo->ref); IRecordInfo_Release(&recinfo->IRecordInfo_iface); @@ -1204,7 +1204,7 @@ static void test_VariantCopy(void)
ok(V_RECORD(&vDst) != (void*)0xdeadbeef && V_RECORD(&vDst) != NULL, "got %p\n", V_RECORD(&vDst)); ok(V_RECORDINFO(&vDst) == &recinfo->IRecordInfo_iface, "got %p\n", V_RECORDINFO(&vDst)); - todo_wine ok(malloc_spy.lastalloc == V_RECORD(&vDst), "%p allocation not seen by IMallocSpy\n",V_RECORD(&vDst)); + ok(malloc_spy.lastalloc == V_RECORD(&vDst), "%p allocation not seen by IMallocSpy\n",V_RECORD(&vDst)); ok(recinfo->getsize == 1, "got %d\n", recinfo->recordclear); ok(recinfo->recordcopy == 1, "got %d\n", recinfo->recordclear);
@@ -1214,7 +1214,7 @@ static void test_VariantCopy(void)
malloc_spy.validptr = (void*)0xdeadbeef; VariantClear(&vSrc); - todo_wine ok(!malloc_spy.validptr, "%p not freed\n",malloc_spy.validptr); + ok(!malloc_spy.validptr, "%p not freed\n",malloc_spy.validptr);
hres = CoRevokeMallocSpy(); ok(hres == S_OK, "ret 0x%08lx\n", hres); @@ -1452,7 +1452,7 @@ static void test_VariantCopyInd(void) ok(V_RECORDINFO(&vDst) == &recinfo->IRecordInfo_iface, "got %p\n", V_RECORDINFO(&vDst)); ok(recinfo->recordclear == 0,"got %d\n", recinfo->recordclear); ok(V_RECORD(&vDst) != (void*)0xdeadbeef, "expected a newly-allocated deep copy\n"); - todo_wine ok(malloc_spy.lastalloc == V_RECORD(&vDst), "%p allocation not seen by IMallocSpy\n",V_RECORD(&vDst)); + ok(malloc_spy.lastalloc == V_RECORD(&vDst), "%p allocation not seen by IMallocSpy\n",V_RECORD(&vDst)); ok(recinfo->getsize == 1,"got %d\n", recinfo->getsize); ok(recinfo->recordcopy == 1,"got %d\n", recinfo->recordcopy); ok(recinfo->ref == 2,"got %ld\n", recinfo->ref); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 885082cc659..a0ac7d0254e 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -654,6 +654,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG* pVarg) IRecordInfo_RecordClear(pBr->pRecInfo, pBr->pvRecord); IRecordInfo_Release(pBr->pRecInfo); } + CoTaskMemFree(pBr->pvRecord); } else if (V_VT(pVarg) == VT_DISPATCH || V_VT(pVarg) == VT_UNKNOWN) @@ -689,7 +690,7 @@ static HRESULT VARIANT_CopyIRecordInfo(VARIANT *dest, const VARIANT *src) /* This could look cleaner if only RecordCreate() was used, but native doesn't use it. Memory should be allocated in a same way as RecordCreate() does, so RecordDestroy() could free it later. */ - dest_rec->pvRecord = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + dest_rec->pvRecord = CoTaskMemAlloc(size); if (!dest_rec->pvRecord) return E_OUTOFMEMORY;
dest_rec->pRecInfo = src_rec->pRecInfo;