Skip to content

Commit 1768d69

Browse files
committed
version_compare: Fix handling of version numbers with a trailing dot
1 parent 8972938 commit 1768d69

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ext/standard/tests/versioning/version_compare.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ foreach ($special_forms as $f1) {
2222
test("1.0$f1", "1.0$f2");
2323
}
2424
}
25+
test("1.2.", "1.2.");
26+
2527
print "TESTING OPERATORS\n";
2628
foreach ($special_forms as $f1) {
2729
foreach ($special_forms as $f2) {
@@ -106,6 +108,7 @@ TESTING COMPARE
106108
1.0pl1 > 1.0rc1
107109
1.0pl1 > 1.0
108110
1.0pl1 = 1.0pl1
111+
1.2. = 1.2.
109112
TESTING OPERATORS
110113
1.0-dev lt 1.0-dev : false
111114
1.0-dev < 1.0-dev : false

ext/standard/versioning.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2)
178178
p2 = n2 + 1;
179179
}
180180
}
181-
if (compare == 0) {
181+
if (compare == 0 && (*p1 || *p2)) {
182182
if (n1 != NULL) {
183183
if (isdigit(*p1)) {
184184
compare = 1;

0 commit comments

Comments
 (0)