diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index 88164d03c71..0e2a748daea 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -3463,7 +3463,8 @@ HRESULT create_doc_uri(HTMLOuterWindow *window, IUri *iuri, nsWineURI **ret)
nsWineURI *uri;
nsresult nsres;
- nsres = create_nsuri(iuri, window, window->doc_obj->nscontainer, NULL, &uri);
+ nsres = create_nsuri(iuri, window, window->doc_obj ? window->doc_obj->nscontainer : NULL,
+ NULL, &uri);
if(NS_FAILED(nsres))
return E_FAIL;