From 777a79cac9d669160733b4d056414cf93de27454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 28 Apr 2026 22:43:48 +0200 Subject: [PATCH 1/2] =?UTF-8?q?zend=5Fobject=5Fhandlers:=20Fix=20type=20of?= =?UTF-8?q?=20`struct=20=5Fzend=5Fobject=5Fhandlers`=E2=80=99s=20`offset`?= =?UTF-8?q?=20field=20(#21900)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is used with `offsetof()` which evaluates to `size_t`. --- Zend/zend_object_handlers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index ec71c427ffce..d0dd804e8a41 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -204,7 +204,7 @@ typedef zend_result (*zend_object_do_operation_t)(uint8_t opcode, zval *result, struct _zend_object_handlers { /* offset of real object header (usually zero) */ - int offset; + size_t offset; /* object handlers */ zend_object_free_obj_t free_obj; /* required */ zend_object_dtor_obj_t dtor_obj; /* required */ From 60b3fa3c76f54c56255c7b07c6543f7853958d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 28 Apr 2026 23:52:44 +0200 Subject: [PATCH 2/2] version_compare: Fix handling of version numbers with a trailing dot (#21689) --- NEWS | 3 +++ ext/standard/tests/versioning/version_compare.phpt | 5 +++++ ext/standard/versioning.c | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b110b17bef21..ef713ddd7255 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.4.22 +- Standard: + . Fixed bug GH-21689 (version_compare() incorrectly handles versions ending + with a dot). (timwolla) 07 May 2026, PHP 8.4.21 diff --git a/ext/standard/tests/versioning/version_compare.phpt b/ext/standard/tests/versioning/version_compare.phpt index 07550dd410f4..e22ddabfa56b 100644 --- a/ext/standard/tests/versioning/version_compare.phpt +++ b/ext/standard/tests/versioning/version_compare.phpt @@ -22,6 +22,9 @@ foreach ($special_forms as $f1) { test("1.0$f1", "1.0$f2"); } } +test("1.2.", "1.2."); +test("1.2..", "1.2.."); + print "TESTING OPERATORS\n"; foreach ($special_forms as $f1) { foreach ($special_forms as $f2) { @@ -106,6 +109,8 @@ TESTING COMPARE 1.0pl1 > 1.0rc1 1.0pl1 > 1.0 1.0pl1 = 1.0pl1 +1.2. = 1.2. +1.2.. = 1.2.. TESTING OPERATORS 1.0-dev lt 1.0-dev : false 1.0-dev < 1.0-dev : false diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c index 6995569fbf87..0ec061d0d86e 100644 --- a/ext/standard/versioning.c +++ b/ext/standard/versioning.c @@ -68,7 +68,15 @@ php_canonicalize_version(const char *version) } lp = *p++; } - *q++ = '\0'; + + /* Check if the last component is empty (i.e. the last character is a dot) + * and remove it if it is. */ + if (*(q - 1) == '.') { + *(q - 1) = '\0'; + } else { + *q = '\0'; + } + return buf; }