diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c
index c481e6afe34..88c456ac10d 100644
--- a/dlls/mshtml/olecmd.c
+++ b/dlls/mshtml/olecmd.c
@@ -873,7 +873,8 @@ void show_context_menu(HTMLDocument *This, DWORD dwID, POINT *ppt)
ppt->x, ppt->y, 0, This->hwnd, NULL);
DestroyMenu(menu_res);
- IOleCommandTarget_Exec(CMDTARGET(This), &CGID_MSHTML, cmdid, 0, NULL, NULL);
+ if(cmdid)
+ IOleCommandTarget_Exec(CMDTARGET(This), &CGID_MSHTML, cmdid, 0, NULL, NULL);
}
void HTMLDocument_OleCmd_Init(HTMLDocument *This)