diff --git a/dlls/itss/protocol.c b/dlls/itss/protocol.c index 51fad3cbef3..2d7cd98dc25 100644 --- a/dlls/itss/protocol.c +++ b/dlls/itss/protocol.c @@ -195,6 +195,10 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, CoTaskMemFree(mime); } + release_chm(This); /* Native leaks handle here */ + This->chm_file = chm_file; + memcpy(&This->chm_object, &chm_object, sizeof(chm_object)); + hres = IInternetProtocolSink_ReportData(pOIProtSink, BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE, chm_object.length, chm_object.length); @@ -206,10 +210,6 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL); - release_chm(This); /* Native leaks handle here */ - This->chm_file = chm_file; - memcpy(&This->chm_object, &chm_object, sizeof(chm_object)); - return report_result(pOIProtSink, hres); } diff --git a/dlls/itss/tests/protocol.c b/dlls/itss/tests/protocol.c index 4b594b2dfa1..70f22b9d26f 100644 --- a/dlls/itss/tests/protocol.c +++ b/dlls/itss/tests/protocol.c @@ -66,6 +66,7 @@ DEFINE_EXPECT(ReportData); DEFINE_EXPECT(ReportResult); static HRESULT expect_hrResult; +static IInternetProtocol *read_protocol = NULL; static enum { ITS_PROTOCOL, @@ -148,11 +149,22 @@ static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWOR else ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION), "grcf = %08x\n", grfBSCF); + if(read_protocol) { + BYTE buf[100]; + DWORD cb = 0xdeadbeef; + HRESULT hres; + + hres = IInternetProtocol_Read(read_protocol, buf, sizeof(buf), &cb); + ok(hres == S_OK, "Read failed: %08x\n", hres); + ok(cb == 13, "cb=%u expected 13\n", cb); + ok(!memcmp(buf, "", 13), "unexpected data\n"); + } + return S_OK; } -static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, DWORD dwError, - LPCWSTR szResult) +static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, + DWORD dwError, LPCWSTR szResult) { CHECK_EXPECT(ReportResult); @@ -365,6 +377,16 @@ static void test_protocol_url(IClassFactory *factory, LPCWSTR url) ok(cb == 2, "cb=%u expected 2\n", cb); ref = IInternetProtocol_Release(protocol); ok(!ref, "protocol ref=%d\n", ref); + + hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&read_protocol); + ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); + if(FAILED(hres)) + return; + + protocol_start(read_protocol, url); + ref = IInternetProtocol_Release(read_protocol); + ok(!ref, "protocol ref=%d\n", ref); + read_protocol = NULL; } static void test_its_protocol(void)