From f14e5fcfbd566491801d3b703f8a430e2e2c7b45 Mon Sep 17 00:00:00 2001 From: SpencerMalone Date: Sun, 12 Oct 2025 12:04:24 -0700 Subject: [PATCH] Fix not thread safe xmlSchemaParse calls in ZTS builds By calling xmlSchemaInitTypes during MINIT. See: https://gitlab.gnome.org/GNOME/libxml2/-/issues/930 Closes GH-20150. --- NEWS | 3 +++ ext/libxml/libxml.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 81bae73f498..42b78f2ade3 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,9 @@ PHP NEWS . Fixed bug GH-20070 (Return type violation in imagefilter when an invalid filter is provided). (Girgias) +- LibXML: + . Fix not thread safe xmlSchemaParse calls. (SpencerMalone) + - Opcache: . Fixed bug GH-20081 (access to uninitialized vars in preload_load()). (Arnaud) diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index eecbca4ed89..6864b25c879 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -39,6 +39,7 @@ #ifdef LIBXML_SCHEMAS_ENABLED #include #include +#include #endif #include "php_libxml.h" @@ -933,7 +934,11 @@ PHP_LIBXML_API void php_libxml_initialize(void) if (!_php_libxml_initialized) { /* we should be the only one's to ever init!! */ ZEND_IGNORE_LEAKS_BEGIN(); + xmlInitParser(); +#ifdef LIBXML_SCHEMAS_ENABLED + xmlSchemaInitTypes(); +#endif ZEND_IGNORE_LEAKS_END(); _php_libxml_default_entity_loader = xmlGetExternalEntityLoader();