From 9c2c0c3d026adbd2a9f369cef2139786cb5fd271 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 22 Feb 2024 23:39:18 +0100 Subject: [PATCH] Remove always-true check --- ext/dom/xpath.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 168316ca289..fe2ac0c3b67 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -135,26 +135,24 @@ PHP_METHOD(DOMXPath, __construct) } intern = Z_XPATHOBJ_P(ZEND_THIS); - if (intern != NULL) { - oldctx = (xmlXPathContextPtr)intern->dom.ptr; - if (oldctx != NULL) { - php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom); - xmlXPathFreeContext(oldctx); - } - - xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "functionString", - (const xmlChar *) "http://php.net/xpath", - dom_xpath_ext_function_string_php); - xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "function", - (const xmlChar *) "http://php.net/xpath", - dom_xpath_ext_function_object_php); - - intern->dom.ptr = ctx; - ctx->userData = (void *)intern; - intern->dom.document = docobj->document; - intern->register_node_ns = register_node_ns; - php_libxml_increment_doc_ref((php_libxml_node_object *) &intern->dom, docp); + oldctx = (xmlXPathContextPtr)intern->dom.ptr; + if (oldctx != NULL) { + php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom); + xmlXPathFreeContext(oldctx); } + + xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "functionString", + (const xmlChar *) "http://php.net/xpath", + dom_xpath_ext_function_string_php); + xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "function", + (const xmlChar *) "http://php.net/xpath", + dom_xpath_ext_function_object_php); + + intern->dom.ptr = ctx; + ctx->userData = (void *)intern; + intern->dom.document = docobj->document; + intern->register_node_ns = register_node_ns; + php_libxml_increment_doc_ref((php_libxml_node_object *) &intern->dom, docp); } /* }}} end DOMXPath::__construct */