diff --git a/ext/dom/document.c b/ext/dom/document.c index 933ea76a4fe..bdb58497b9d 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1625,7 +1625,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int optio EG(error_reporting) = old_error_reporting; } /* If loading from memory, set the base reference uri for the document */ - if (ret->URL == NULL && ctxt->directory != NULL) { + if (ret && ret->URL == NULL && ctxt->directory != NULL) { ret->URL = xmlStrdup(ctxt->directory); } } else {