mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix str_decrement() on "1"
Closes GH-12339
This commit is contained in:
3
NEWS
3
NEWS
@@ -25,6 +25,9 @@ PHP NEWS
|
||||
- SimpleXML:
|
||||
. Apply iterator fixes only on master. (nielsdos)
|
||||
|
||||
- Standard:
|
||||
. Fixed str_decrement() on "1". (ilutov)
|
||||
|
||||
- XSL:
|
||||
. Fix type error on XSLTProcessor::transformToDoc return value with
|
||||
SimpleXML. (nielsdos)
|
||||
|
||||
@@ -1289,7 +1289,7 @@ PHP_FUNCTION(str_decrement)
|
||||
}
|
||||
} while (carry && position-- > 0);
|
||||
|
||||
if (UNEXPECTED(carry || ZSTR_VAL(decremented)[0] == '0')) {
|
||||
if (UNEXPECTED(carry || (ZSTR_VAL(decremented)[0] == '0' && ZSTR_LEN(decremented) > 1))) {
|
||||
if (ZSTR_LEN(decremented) == 1) {
|
||||
zend_string_release_ex(decremented, /* persistent */ false);
|
||||
zend_argument_value_error(1, "\"%s\" is out of decrement range", ZSTR_VAL(str));
|
||||
|
||||
@@ -28,6 +28,7 @@ $strictlyAlphaNumeric = [
|
||||
"d",
|
||||
"D",
|
||||
"4",
|
||||
"1",
|
||||
];
|
||||
|
||||
foreach ($strictlyAlphaNumeric as $s) {
|
||||
@@ -77,3 +78,5 @@ string(1) "C"
|
||||
string(1) "D"
|
||||
string(1) "3"
|
||||
string(1) "4"
|
||||
string(1) "0"
|
||||
string(1) "1"
|
||||
|
||||
Reference in New Issue
Block a user