diff --git a/dlls/mshtml/binding.h b/dlls/mshtml/binding.h
index 392713b56f8..d95354165d1 100644
--- a/dlls/mshtml/binding.h
+++ b/dlls/mshtml/binding.h
@@ -118,7 +118,7 @@ HRESULT navigate_new_window(HTMLOuterWindow*,IUri*,const WCHAR*,IHTMLWindow2**)
HRESULT navigate_url(HTMLOuterWindow*,const WCHAR*,IUri*,DWORD) DECLSPEC_HIDDEN;
HRESULT create_channelbsc(IMoniker*,const WCHAR*,BYTE*,DWORD,BOOL,nsChannelBSC**) DECLSPEC_HIDDEN;
-HRESULT channelbsc_load_stream(HTMLInnerWindow*,IStream*) DECLSPEC_HIDDEN;
+HRESULT channelbsc_load_stream(HTMLInnerWindow*,IMoniker*,IStream*) DECLSPEC_HIDDEN;
void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*) DECLSPEC_HIDDEN;
IUri *nsuri_get_uri(nsWineURI*) DECLSPEC_HIDDEN;
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index 2c0666e464f..4e6ed611254 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -1953,7 +1953,7 @@ void abort_window_bindings(HTMLInnerWindow *window)
}
}
-HRESULT channelbsc_load_stream(HTMLInnerWindow *pending_window, IStream *stream)
+HRESULT channelbsc_load_stream(HTMLInnerWindow *pending_window, IMoniker *mon, IStream *stream)
{
nsChannelBSC *bscallback = pending_window->bscallback;
HRESULT hres = S_OK;
@@ -1967,6 +1967,8 @@ HRESULT channelbsc_load_stream(HTMLInnerWindow *pending_window, IStream *stream)
if(!bscallback->nschannel->content_type)
return E_OUTOFMEMORY;
+ set_current_mon(pending_window->base.outer_window, mon, 0);
+
bscallback->bsc.window = pending_window;
if(stream)
hres = read_stream_data(bscallback, stream);
diff --git a/dlls/mshtml/persist.c b/dlls/mshtml/persist.c
index 8f36c750f18..8c0ad683968 100644
--- a/dlls/mshtml/persist.c
+++ b/dlls/mshtml/persist.c
@@ -844,11 +844,12 @@ static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM
prepare_for_binding(This, mon, FALSE);
hres = set_moniker(This->window, mon, NULL, NULL, NULL, TRUE);
- IMoniker_Release(mon);
if(FAILED(hres))
return hres;
- return channelbsc_load_stream(This->window->pending_window, pStm);
+ hres = channelbsc_load_stream(This->window->pending_window, mon, pStm);
+ IMoniker_Release(mon);
+ return hres;
}
static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
@@ -901,11 +902,12 @@ static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
prepare_for_binding(This, mon, FALSE);
hres = set_moniker(This->window, mon, NULL, NULL, NULL, FALSE);
- IMoniker_Release(mon);
if(FAILED(hres))
return hres;
- return channelbsc_load_stream(This->window->pending_window, NULL);
+ hres = channelbsc_load_stream(This->window->pending_window, mon, NULL);
+ IMoniker_Release(mon);
+ return hres;
}
static const IPersistStreamInitVtbl PersistStreamInitVtbl = {