diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c
index b65351744..b3bed1bbf 100644
--- a/src/document/html/renderer.c
+++ b/src/document/html/renderer.c
@@ -1970,7 +1970,8 @@ html_special(struct html_context *html_context, enum html_special_type c, ...)
unsigned long seconds = va_arg(l, unsigned long);
unsigned char *t = va_arg(l, unsigned char *);
- document->refresh = init_document_refresh(t, seconds);
+ if (document)
+ document->refresh = init_document_refresh(t, seconds);
break;
}
case SP_COLOR_LINK_LINES: