Skip to content

Commit 1df8293

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix str_decrement() on "1"
2 parents dab5aba + b31a5b2 commit 1df8293

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ PHP_FUNCTION(str_decrement)
12891289
}
12901290
} while (carry && position-- > 0);
12911291

1292-
if (UNEXPECTED(carry || ZSTR_VAL(decremented)[0] == '0')) {
1292+
if (UNEXPECTED(carry || (ZSTR_VAL(decremented)[0] == '0' && ZSTR_LEN(decremented) > 1))) {
12931293
if (ZSTR_LEN(decremented) == 1) {
12941294
zend_string_release_ex(decremented, /* persistent */ false);
12951295
zend_argument_value_error(1, "\"%s\" is out of decrement range", ZSTR_VAL(str));

ext/standard/tests/strings/str_decrement_basic.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ $strictlyAlphaNumeric = [
2828
"d",
2929
"D",
3030
"4",
31+
"1",
3132
];
3233

3334
foreach ($strictlyAlphaNumeric as $s) {
@@ -77,3 +78,5 @@ string(1) "C"
7778
string(1) "D"
7879
string(1) "3"
7980
string(1) "4"
81+
string(1) "0"
82+
string(1) "1"

0 commit comments

Comments
 (0)