From 566babac588c641fde93c738deac2f391f71a643 Mon Sep 17 00:00:00 2001
From: Rob Richards <rrichards@php.net>
Date: Mon, 26 Jan 2009 19:11:19 +0000
Subject: [PATCH] MFH: fix bug #47220 (segfault in dom_document_parser in
 recovery mode)

---
 ext/dom/document.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/dom/document.c b/ext/dom/document.c
index b154232f33..1927852a11 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -1687,7 +1687,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 {
-- 
2.40.0