Skip to content

Commit a28b1f3

Browse files
committed
Address review
1 parent c314174 commit a28b1f3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Zend/zend_operators.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,6 @@ static void ZEND_FASTCALL increment_string(zval *str) /* {{{ */
25322532
}
25332533
}
25342534

2535-
25362535
if (!Z_REFCOUNTED_P(str)) {
25372536
Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
25382537
Z_TYPE_INFO_P(str) = IS_STRING_EX;
@@ -2666,7 +2665,7 @@ ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1) /* {{{ */
26662665
if (Z_OBJ_HT_P(op1)->cast_object(Z_OBJ_P(op1), &tmp, _IS_NUMBER) == SUCCESS) {
26672666
ZEND_ASSERT(Z_TYPE(tmp) == IS_LONG || Z_TYPE(tmp) == IS_DOUBLE);
26682667
zval_ptr_dtor(op1);
2669-
ZVAL_COPY(op1, &tmp);
2668+
ZVAL_COPY_VALUE(op1, &tmp);
26702669
goto try_again;
26712670
}
26722671
ZEND_FALLTHROUGH;

ext/standard/string.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,8 @@ PHP_FUNCTION(str_increment)
12151215

12161216
do {
12171217
char c = ZSTR_VAL(incremented)[position];
1218-
if (EXPECTED( (c >= 'a' && c < 'z') || (c >= 'A' && c < 'Z') || (c >= '0' && c < '9') )) {
1218+
/* We know c is in ['a', 'z'], ['A', 'Z'], or ['0', '9'] range from zend_string_only_has_ascii_alphanumeric() */
1219+
if (EXPECTED( c != 'z' && c != 'Z' && c != '9' )) {
12191220
carry = false;
12201221
ZSTR_VAL(incremented)[position]++;
12211222
} else { /* if 'z', 'Z', or '9' */
@@ -1270,7 +1271,8 @@ PHP_FUNCTION(str_decrement)
12701271

12711272
do {
12721273
char c = ZSTR_VAL(decremented)[position];
1273-
if (EXPECTED( (c > 'a' && c <= 'z') || (c > 'A' && c <= 'Z') || (c > '0' && c <= '9') )) {
1274+
/* We know c is in ['a', 'z'], ['A', 'Z'], or ['0', '9'] range from zend_string_only_has_ascii_alphanumeric() */
1275+
if (EXPECTED( c != 'a' && c != 'A' && c != '0' )) {
12741276
carry = false;
12751277
ZSTR_VAL(decremented)[position]--;
12761278
} else { /* if 'a', 'A', or '0' */

0 commit comments

Comments
 (0)