From 1768d69e725f40e1bf7a3da71d0ef6fa3a1bb91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 9 Apr 2026 15:55:37 +0200 Subject: [PATCH] version_compare: Fix handling of version numbers with a trailing dot --- ext/standard/tests/versioning/version_compare.phpt | 3 +++ ext/standard/versioning.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/standard/tests/versioning/version_compare.phpt b/ext/standard/tests/versioning/version_compare.phpt index 07550dd410f4..cd7dfef06654 100644 --- a/ext/standard/tests/versioning/version_compare.phpt +++ b/ext/standard/tests/versioning/version_compare.phpt @@ -22,6 +22,8 @@ foreach ($special_forms as $f1) { test("1.0$f1", "1.0$f2"); } } +test("1.2.", "1.2."); + print "TESTING OPERATORS\n"; foreach ($special_forms as $f1) { foreach ($special_forms as $f2) { @@ -106,6 +108,7 @@ TESTING COMPARE 1.0pl1 > 1.0rc1 1.0pl1 > 1.0 1.0pl1 = 1.0pl1 +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..177e5e66c222 100644 --- a/ext/standard/versioning.c +++ b/ext/standard/versioning.c @@ -178,7 +178,7 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2) p2 = n2 + 1; } } - if (compare == 0) { + if (compare == 0 && (*p1 || *p2)) { if (n1 != NULL) { if (isdigit(*p1)) { compare = 1;