From 16d537a2b36d7863d54c67e16188bbc347357afa Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:34:06 +0200 Subject: [PATCH] Use unsigned int instead of int for refcount for libxml objects --- UPGRADING.INTERNALS | 1 + ext/dom/document.c | 4 ++-- ext/libxml/php_libxml.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 236b9b980265b..b4466c988d8f6 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -301,6 +301,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES - Added php_libxml_uses_internal_errors(). - Added a way to override document handlers (e.g. serialization) with php_libxml_document_handlers. + - Changed the refcount fields from int to unsigned int. e. ext/date - Added the php_format_date_ex() API to format instances of php_date_obj. diff --git a/ext/dom/document.c b/ext/dom/document.c index 56bbc07d41e1d..a941eb75fd5b3 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1243,7 +1243,7 @@ PHP_METHOD(DOMDocument, __construct) dom_object *intern; char *encoding, *version = NULL; size_t encoding_len = 0, version_len = 0; - int refcount; + unsigned int refcount; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &version, &version_len, &encoding, &encoding_len) == FAILURE) { RETURN_THROWS(); @@ -1476,7 +1476,7 @@ static void php_dom_finish_loading_document(zval *this, zval *return_value, xmlD php_libxml_decrement_node_ptr((php_libxml_node_object *) intern); doc_prop = intern->document->doc_props; intern->document->doc_props = NULL; - int refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern); + unsigned int refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern); if (refcount != 0) { docp->_private = NULL; } diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index 9c2682504e18f..4bf260c3efb03 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -113,14 +113,14 @@ typedef struct _php_libxml_ref_obj { php_libxml_cache_tag cache_tag; php_libxml_private_data_header *private_data; const php_libxml_document_handlers *handlers; - int refcount; + unsigned int refcount; php_libxml_class_type class_type : 8; php_libxml_quirks_mode quirks_mode : 8; } php_libxml_ref_obj; typedef struct _php_libxml_node_ptr { xmlNodePtr node; - int refcount; + unsigned int refcount; void *_private; } php_libxml_node_ptr;