From 75229cb127c781e471583faec69290054f7b0a97 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 10 Jul 2023 21:47:11 +0200 Subject: [PATCH] Cleanup php_libxml_node_decrement_resource() obj_node is already checked, so checking it again in the second if is not necessary. Merge declarations and assignments while we're at it. --- ext/libxml/libxml.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index b32caab0a84..a8de9bd6d65 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -1344,18 +1344,14 @@ PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node) PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *object) { - int ret_refcount = -1; - xmlNodePtr nodep; - php_libxml_node_ptr *obj_node; - if (object != NULL && object->node != NULL) { - obj_node = (php_libxml_node_ptr *) object->node; - nodep = object->node->node; - ret_refcount = php_libxml_decrement_node_ptr(object); + php_libxml_node_ptr *obj_node = (php_libxml_node_ptr *) object->node; + xmlNodePtr nodep = obj_node->node; + int ret_refcount = php_libxml_decrement_node_ptr(object); if (ret_refcount == 0) { php_libxml_node_free_resource(nodep); } else { - if (obj_node && object == obj_node->_private) { + if (object == obj_node->_private) { obj_node->_private = NULL; } }