Commit 1b936769 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

oleaut32: Fix some memory leaks in the safearray tests.

parent e28fe907
...@@ -355,15 +355,24 @@ static void test_safearray(void) ...@@ -355,15 +355,24 @@ static void test_safearray(void)
SafeArrayPtrOfIndex(a, indices, (void **)&ptr1); SafeArrayPtrOfIndex(a, indices, (void **)&ptr1);
ok(*(WORD *)ptr1 == 0x55aa, "Data not preserved when resizing array\n"); ok(*(WORD *)ptr1 == 0x55aa, "Data not preserved when resizing array\n");
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD faild with hres %x\n", hres);
bounds[0].cElements = 0; bounds[0].lLbound = 1; bounds[0].cElements = 0; bounds[0].lLbound = 1;
bounds[1].cElements = 2; bounds[1].lLbound = 23; bounds[1].cElements = 2; bounds[1].lLbound = 23;
a = SafeArrayCreate(VT_I4,2,bounds); a = SafeArrayCreate(VT_I4,2,bounds);
ok(a != NULL,"SAC(VT_INT32,2,...) with 0 element dim failed.\n"); ok(a != NULL,"SAC(VT_INT32,2,...) with 0 element dim failed.\n");
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD faild with hres %x\n", hres);
bounds[0].cElements = 1; bounds[0].lLbound = 1; bounds[0].cElements = 1; bounds[0].lLbound = 1;
bounds[1].cElements = 0; bounds[1].lLbound = 23; bounds[1].cElements = 0; bounds[1].lLbound = 23;
a = SafeArrayCreate(VT_I4,2,bounds); a = SafeArrayCreate(VT_I4,2,bounds);
ok(a != NULL,"SAC(VT_INT32,2,...) with 0 element dim failed.\n"); ok(a != NULL,"SAC(VT_INT32,2,...) with 0 element dim failed.\n");
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD faild with hres %x\n", hres);
bounds[0].cElements = 42; bounds[0].lLbound = 1; bounds[0].cElements = 42; bounds[0].lLbound = 1;
bounds[1].cElements = 2; bounds[1].lLbound = 23; bounds[1].cElements = 2; bounds[1].lLbound = 23;
a = SafeArrayCreate(VT_I4,2,bounds); a = SafeArrayCreate(VT_I4,2,bounds);
...@@ -443,6 +452,9 @@ static void test_safearray(void) ...@@ -443,6 +452,9 @@ static void test_safearray(void)
hres = SafeArrayUnaccessData(a); hres = SafeArrayUnaccessData(a);
ok(S_OK == hres, "SAUAD failed with 0x%x\n", hres); ok(S_OK == hres, "SAUAD failed with 0x%x\n", hres);
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD faild with hres %x\n", hres);
for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) { for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
if ((i == VT_I8 || i == VT_UI8) && HAVE_OLEAUT32_I8) if ((i == VT_I8 || i == VT_UI8) && HAVE_OLEAUT32_I8)
{ {
...@@ -513,6 +525,9 @@ static void test_safearray(void) ...@@ -513,6 +525,9 @@ static void test_safearray(void)
ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %x\n", vttypes[i].vt, hres); ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %x\n", vttypes[i].vt, hres);
} }
hres = SafeArrayDestroy(c);
ok(hres == S_OK,"SAD faild with hres %x\n", hres);
hres = SafeArrayDestroy(a); hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD of array with vt %d failed with hres %x\n", vttypes[i].vt, hres); ok(hres == S_OK,"SAD of array with vt %d failed with hres %x\n", vttypes[i].vt, hres);
} }
...@@ -531,6 +546,7 @@ static void test_safearray(void) ...@@ -531,6 +546,7 @@ static void test_safearray(void)
ok(hres==S_OK, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR failed with %x\n",hres); ok(hres==S_OK, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR failed with %x\n",hres);
ok(V_VT(&v) == VT_BSTR,"CTE VT_ARRAY|VT_UI1 -> VT_BSTR did not return VT_BSTR, but %d.v\n",V_VT(&v)); ok(V_VT(&v) == VT_BSTR,"CTE VT_ARRAY|VT_UI1 -> VT_BSTR did not return VT_BSTR, but %d.v\n",V_VT(&v));
ok(V_BSTR(&v)[0] == 0x6548,"First letter are not 'He', but %x\n", V_BSTR(&v)[0]); ok(V_BSTR(&v)[0] == 0x6548,"First letter are not 'He', but %x\n", V_BSTR(&v)[0]);
VariantClear(&v);
/* check locking functions */ /* check locking functions */
a = SafeArrayCreate(VT_I4, 1, &bound); a = SafeArrayCreate(VT_I4, 1, &bound);
...@@ -560,7 +576,6 @@ static void test_safearray(void) ...@@ -560,7 +576,6 @@ static void test_safearray(void)
hres = SafeArrayDestroyDescriptor(a); hres = SafeArrayDestroyDescriptor(a);
ok(hres == S_OK,"SADD with data in array failed with hres %x\n",hres); ok(hres == S_OK,"SADD with data in array failed with hres %x\n",hres);
/* IID functions */ /* IID functions */
/* init a small stack safearray */ /* init a small stack safearray */
if (pSafeArraySetIID) { if (pSafeArraySetIID) {
...@@ -574,6 +589,9 @@ static void test_safearray(void) ...@@ -574,6 +589,9 @@ static void test_safearray(void)
ok((a->fFeatures & FADF_HAVEIID) == 0,"newly allocated descriptor with SAAD should not have FADF_HAVEIID\n"); ok((a->fFeatures & FADF_HAVEIID) == 0,"newly allocated descriptor with SAAD should not have FADF_HAVEIID\n");
hres = pSafeArraySetIID(a,&iid); hres = pSafeArraySetIID(a,&iid);
ok(hres == E_INVALIDARG,"SafeArraySetIID of newly allocated descriptor with SAAD should return E_INVALIDARG, but %x\n",hres); ok(hres == E_INVALIDARG,"SafeArraySetIID of newly allocated descriptor with SAAD should return E_INVALIDARG, but %x\n",hres);
hres = SafeArrayDestroyDescriptor(a);
ok(hres == S_OK,"SADD failed with hres %x\n",hres);
} }
if (!pSafeArrayAllocDescriptorEx) if (!pSafeArrayAllocDescriptorEx)
...@@ -692,6 +710,9 @@ static void test_SafeArrayAllocDestroyDescriptor(void) ...@@ -692,6 +710,9 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
hres = SafeArrayAllocData(sa); hres = SafeArrayAllocData(sa);
ok(hres == S_OK, "SafeArrayAllocData gave hres 0x%x\n", hres); ok(hres == S_OK, "SafeArrayAllocData gave hres 0x%x\n", hres);
hres = SafeArrayDestroy(sa);
ok(hres == S_OK,"SafeArrayDestroy failed with hres %x\n",hres);
} }
static void test_SafeArrayCreateLockDestroy(void) static void test_SafeArrayCreateLockDestroy(void)
...@@ -808,7 +829,7 @@ static void test_SafeArrayCreateLockDestroy(void) ...@@ -808,7 +829,7 @@ static void test_SafeArrayCreateLockDestroy(void)
ok(hres == S_OK, "Unlock VARTYPE %d (@%d dims) hres 0x%x\n", ok(hres == S_OK, "Unlock VARTYPE %d (@%d dims) hres 0x%x\n",
vt, dimension, hres); vt, dimension, hres);
hres = SafeArrayDestroyDescriptor(sa); hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "destroy VARTYPE %d (@%d dims) hres 0x%x\n", ok(hres == S_OK, "destroy VARTYPE %d (@%d dims) hres 0x%x\n",
vt, dimension, hres); vt, dimension, hres);
} }
...@@ -829,6 +850,9 @@ static void test_VectorCreateLockDestroy(void) ...@@ -829,6 +850,9 @@ static void test_VectorCreateLockDestroy(void)
sa = pSafeArrayCreateVector(VT_UI1, 0, 0); sa = pSafeArrayCreateVector(VT_UI1, 0, 0);
ok(sa != NULL, "SACV with 0 elements failed.\n"); ok(sa != NULL, "SACV with 0 elements failed.\n");
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "SafeArrayDestroy failed with hres %x\n",hres);
/* Test all VARTYPES in different lengths */ /* Test all VARTYPES in different lengths */
for (element = 1; element <= 101; element += 10) for (element = 1; element <= 101; element += 10)
{ {
...@@ -861,7 +885,7 @@ static void test_VectorCreateLockDestroy(void) ...@@ -861,7 +885,7 @@ static void test_VectorCreateLockDestroy(void)
ok(hres == S_OK, "Unlock VARTYPE %d (@%d elements) failed; hres 0x%x\n", ok(hres == S_OK, "Unlock VARTYPE %d (@%d elements) failed; hres 0x%x\n",
vt, element, hres); vt, element, hres);
hres = SafeArrayDestroyDescriptor(sa); hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "destroy VARTYPE %d (@%d elements) failed; hres 0x%x\n", ok(hres == S_OK, "destroy VARTYPE %d (@%d elements) failed; hres 0x%x\n",
vt, element, hres); vt, element, hres);
} }
...@@ -1085,6 +1109,8 @@ static void test_SafeArrayGetPutElement_BSTR(void) ...@@ -1085,6 +1109,8 @@ static void test_SafeArrayGetPutElement_BSTR(void)
if (hres == S_OK) if (hres == S_OK)
ok(SysStringLen(value) == SysStringLen(gotvalue), "Got len %d instead of %d\n", SysStringLen(gotvalue), SysStringLen(value)); ok(SysStringLen(value) == SysStringLen(gotvalue), "Got len %d instead of %d\n", SysStringLen(gotvalue), SysStringLen(value));
SafeArrayDestroy(sa); SafeArrayDestroy(sa);
SysFreeString(value);
SysFreeString(gotvalue);
} }
static int tunk_xref = 0; static int tunk_xref = 0;
...@@ -1603,6 +1629,7 @@ static void test_SafeArrayChangeTypeEx(void) ...@@ -1603,6 +1629,7 @@ static void test_SafeArrayChangeTypeEx(void)
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_BSTR); hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_BSTR);
ok(hres != S_OK, "CTE VT_ARRAY|VT %d->BSTR succeeded\n", vt); ok(hres != S_OK, "CTE VT_ARRAY|VT %d->BSTR succeeded\n", vt);
VariantClear(&v2); VariantClear(&v2);
VariantClear(&v);
} }
/* Can't change an array of one type into array of another type , even /* Can't change an array of one type into array of another type , even
...@@ -1630,6 +1657,7 @@ static void test_SafeArrayChangeTypeEx(void) ...@@ -1630,6 +1657,7 @@ static void test_SafeArrayChangeTypeEx(void)
V_ARRAY(&v) = sa; V_ARRAY(&v) = sa;
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_ARRAY|VT_UI1); hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_ARRAY|VT_UI1);
ok(hres == S_OK, "CTE VT_ARRAY|VT_UI1->VT_ARRAY|VT_UI1 returned %x\n", hres); ok(hres == S_OK, "CTE VT_ARRAY|VT_UI1->VT_ARRAY|VT_UI1 returned %x\n", hres);
SafeArrayDestroy(sa);
} }
/* NULL/EMPTY */ /* NULL/EMPTY */
......
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