diff --git a/src/html/m_image.cpp b/src/html/m_image.cpp
index 3f479801f6..4ab735e28a 100644
--- a/src/html/m_image.cpp
+++ b/src/html/m_image.cpp
@@ -326,7 +326,7 @@ wxHtmlImageCell::wxHtmlImageCell(wxWindow *window, wxFSFile *input,
int w, int h, double scale, int align,
const wxString& mapname) : wxHtmlCell()
{
- m_window = wxStaticCast(window, wxScrolledWindow);
+ m_window = window ? wxStaticCast(window, wxScrolledWindow) : NULL;
m_scale = scale;
m_bitmap = NULL;
m_bmpW = w;