[php-src] Issue #25397: Potential NULL pointer dereference in php_dom_create_fake_namespace_decl_node_ptr()

From: Date: Wed, 11 Nov 2026 17:52:04 +0000
Subject: [php-src] Issue #25397: Potential NULL pointer dereference in php_dom_create_fake_namespace_decl_node_ptr()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-254123@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25397 Author: Ti-Mis ### Description Hi, my static analyzer, Svace, has found a potential bug. Could you take a look and provide some feedback? Description The function php_dom_create_fake_namespace_decl_node_ptr() dereferences the return value of xmlNewNs() without checking whether it is NULL. ```php xmlNsPtr curns = xmlNewNs(NULL, original->href, NULL); if (original->prefix) { curns->prefix = xmlStrdup(original->prefix); } <?php ``` Since xmlNewNs() may return NULL on allocation failure, a non-NULL original->prefix can cause a NULL pointer dereference when accessing curns->prefix. Impact This may lead to a crash of the PHP process, potentially resulting in a denial of service (DoS) when processing DOM namespace nodes. The affected function is called from dom_object_namespace_node_clone_obj() and php_dom_create_fake_namespace_decl(), making the issue relevant to namespace node cloning and creation. Proposed Solution Check the return value of xmlNewNs() before dereferencing curns and handle allocation failures appropriately. Additionally, ensure that callers correctly handle a failure to create the fake namespace declaration node. ### PHP Version ```plain PHP 8.3.31 ``` ### Operating System _No response_

« previous php.bugs (#254123) next »