Commit bcd6e9f3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Fix implementation of ReleaseBindInfo.

parent 27b5c54f
......@@ -58,6 +58,7 @@ DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xA
DEFINE_EXPECT(ParseUrl);
DEFINE_EXPECT(QI_IInternetProtocolInfo);
DEFINE_EXPECT(CreateInstance);
DEFINE_EXPECT(unk_Release);
static void test_CreateFormatEnum(void)
{
......@@ -829,6 +830,50 @@ static void test_NameSpace(void)
IInternetSession_Release(session);
}
static ULONG WINAPI unk_Release(IUnknown *iface)
{
CHECK_EXPECT(unk_Release);
return 0;
}
static const IUnknownVtbl unk_vtbl = {
(void*)0xdeadbeef,
(void*)0xdeadbeef,
unk_Release
};
static void test_ReleaseBindInfo(void)
{
BINDINFO bi;
IUnknown unk = { &unk_vtbl };
ReleaseBindInfo(NULL); /* shouldn't crash */
memset(&bi, 0, sizeof(bi));
bi.cbSize = sizeof(BINDINFO);
bi.pUnk = &unk;
SET_EXPECT(unk_Release);
ReleaseBindInfo(&bi);
ok(bi.cbSize == sizeof(BINDINFO), "bi.cbSize=%ld, expected %d\n",
bi.cbSize, sizeof(bi));
ok(bi.pUnk == NULL, "bi.pUnk=%p, expected NULL\n", bi.pUnk);
CHECK_CALLED(unk_Release);
memset(&bi, 0, sizeof(bi));
bi.cbSize = offsetof(BINDINFO, pUnk);
bi.pUnk = &unk;
ReleaseBindInfo(&bi);
ok(bi.cbSize == offsetof(BINDINFO, pUnk), "bi.cbSize=%ld, expected %d\n",
bi.cbSize, sizeof(bi));
ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
memset(&bi, 0, sizeof(bi));
bi.pUnk = &unk;
ReleaseBindInfo(&bi);
ok(!bi.cbSize, "bi.cbSize=%ld, expected 0\n", bi.cbSize);
ok(bi.pUnk == &unk, "bi.pUnk=%p, expected %p\n", bi.pUnk, &unk);
}
START_TEST(misc)
{
OleInitialize(NULL);
......@@ -842,6 +887,7 @@ START_TEST(misc)
test_SecurityManager();
test_ZoneManager();
test_NameSpace();
test_ReleaseBindInfo();
OleUninitialize();
}
......@@ -35,6 +35,7 @@
#include "winuser.h"
#include "urlmon.h"
#include "urlmon_main.h"
#include "ole2.h"
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
......@@ -370,15 +371,25 @@ HRESULT WINAPI CoGetClassObjectFromURL( REFCLSID rclsid, LPCWSTR szCodeURL, DWOR
*/
void WINAPI ReleaseBindInfo(BINDINFO* pbindinfo)
{
DWORD size;
TRACE("(%p)\n", pbindinfo);
if(!pbindinfo)
if(!pbindinfo || !(size = pbindinfo->cbSize))
return;
CoTaskMemFree(pbindinfo->szExtraInfo);
ReleaseStgMedium(&pbindinfo->stgmedData);
if(offsetof(BINDINFO, szExtraInfo) < size)
CoTaskMemFree(pbindinfo->szCustomVerb);
if(pbindinfo->pUnk)
if(pbindinfo->pUnk && offsetof(BINDINFO, pUnk) < size)
IUnknown_Release(pbindinfo->pUnk);
memset(pbindinfo, 0, size);
pbindinfo->cbSize = size;
}
/***********************************************************************
......
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