Skip to content

Commit 55f339d

Browse files
committed
Avoid passing NULL to xmlSwitchToEncoding
This otherwise switches to UTF-8 on libxml2 2.12.0
1 parent 6bd680b commit 55f339d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/dom/document.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,10 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source,
12401240
return(NULL);
12411241
}
12421242

1243-
(void) xmlSwitchToEncoding(ctxt, encoding);
1243+
if (encoding != NULL) {
1244+
/* Note: libxml 2.12+ don't handle NULL encoding well. */
1245+
(void) xmlSwitchToEncoding(ctxt, encoding);
1246+
}
12441247

12451248
/* If loading from memory, we need to set the base directory for the document */
12461249
if (mode != DOM_LOAD_FILE) {

0 commit comments

Comments
 (0)