From 5185d46ccc2f3858d343c5cf4edc5bc4220c7cd1 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Tue, 11 Nov 2025 00:01:38 +0100 Subject: [PATCH] Fix zero-extension on range() char parameters --- ext/standard/array.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/array.c b/ext/standard/array.c index 6de17f2bff7..0389eb1840a 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3049,9 +3049,9 @@ PHP_FUNCTION(range) goto handle_numeric_inputs; } - /* Generate array of characters, as ints to make bounds checking possible in the loop condition */ - int low = Z_STRVAL_P(user_start)[0]; - int high = Z_STRVAL_P(user_end)[0]; + /* Generate array of characters, as zero-extended ints to make bounds checking possible in the loop condition */ + int low = (unsigned char) Z_STRVAL_P(user_start)[0]; + int high = (unsigned char) Z_STRVAL_P(user_end)[0]; /* Decreasing char range */ if (low > high) {