diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 441346be56c..1a3f7b9e83e 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -3158,6 +3158,8 @@ static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttri
/* filter property is a special case */
if(style_entry->compat_dispid == DISPID_IHTMLSTYLE_FILTER) {
+ if(!This->elem)
+ return E_UNEXPECTED;
*pfSuccess = variant_bool(This->elem->filter && *This->elem->filter);
heap_free(This->elem->filter);
This->elem->filter = NULL;