diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index dede0a7738d..0fad7aab2e7 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -803,7 +803,7 @@ static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigato
TRACE("(%p)->(%p)\n", This, p);
*p = OmNavigator_Create();
- return S_OK;
+ return *p ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c
index 6d7ec158b40..51421d3a9ca 100644
--- a/dlls/mshtml/omnavigator.c
+++ b/dlls/mshtml/omnavigator.c
@@ -941,6 +941,9 @@ IOmNavigator *OmNavigator_Create(void)
OmNavigator *ret;
ret = heap_alloc_zero(sizeof(*ret));
+ if(!ret)
+ return NULL;
+
ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
ret->ref = 1;