Skip to content

Commit 5185d46

Browse files
committed
Fix zero-extension on range() char parameters
1 parent 9d9f979 commit 5185d46

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/standard/array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,9 +3049,9 @@ PHP_FUNCTION(range)
30493049
goto handle_numeric_inputs;
30503050
}
30513051

3052-
/* Generate array of characters, as ints to make bounds checking possible in the loop condition */
3053-
int low = Z_STRVAL_P(user_start)[0];
3054-
int high = Z_STRVAL_P(user_end)[0];
3052+
/* Generate array of characters, as zero-extended ints to make bounds checking possible in the loop condition */
3053+
int low = (unsigned char) Z_STRVAL_P(user_start)[0];
3054+
int high = (unsigned char) Z_STRVAL_P(user_end)[0];
30553055

30563056
/* Decreasing char range */
30573057
if (low > high) {

0 commit comments

Comments
 (0)