diff --git a/ext/standard/array.c b/ext/standard/array.c index d95ea012ad6b..a84fa50d61f0 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2859,8 +2859,11 @@ PHP_FUNCTION(array_fill_keys) #define RANGE_CHECK_DOUBLE_INIT_ARRAY(start, end, _step) do { \ double __calc_size = ((start - end) / (_step)) + 1; \ if (__calc_size >= (double)HT_MAX_SIZE) { \ + double __exceed_by = __calc_size - (double)HT_MAX_SIZE; \ zend_value_error(\ - "The supplied range exceeds the maximum array size: start=%0.1f end=%0.1f step=%0.1f", end, start, (_step)); \ + "The supplied range exceeds the maximum array size by %.1f elements: " \ + "start=%.1f, end=%.1f, step=%.1f. Max size: %.0f", \ + __exceed_by, end, start, (_step), (double)HT_MAX_SIZE); \ RETURN_THROWS(); \ } \ size = (uint32_t)_php_math_round(__calc_size, 0, PHP_ROUND_HALF_UP); \ @@ -2871,8 +2874,12 @@ PHP_FUNCTION(array_fill_keys) #define RANGE_CHECK_LONG_INIT_ARRAY(start, end, _step) do { \ zend_ulong __calc_size = ((zend_ulong) start - end) / (_step); \ if (__calc_size >= HT_MAX_SIZE - 1) { \ + uint64_t __excess = __calc_size - (HT_MAX_SIZE - 1); \ zend_value_error(\ - "The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT " step=" ZEND_LONG_FMT, end, start, (_step)); \ + "The supplied range exceeds the maximum array size by %" PRIu64 " elements: " \ + "start=" ZEND_LONG_FMT ", end=" ZEND_LONG_FMT ", step=" ZEND_LONG_FMT ". " \ + "Calculated size: %" PRIu64 ". Maximum size: %" PRIu64 ".", \ + __excess, end, start, (_step), (uint64_t)__calc_size, (uint64_t)HT_MAX_SIZE); \ RETURN_THROWS(); \ } \ size = (uint32_t)(__calc_size + 1); \ diff --git a/ext/standard/tests/array/range/range_bug70239_2.phpt b/ext/standard/tests/array/range/range_bug70239_2.phpt index a4ec3c556351..b20f360dba18 100644 --- a/ext/standard/tests/array/range/range_bug70239_2.phpt +++ b/ext/standard/tests/array/range/range_bug70239_2.phpt @@ -9,4 +9,4 @@ try { } ?> --EXPECTF-- -The supplied range exceeds the maximum array size: start=0 end=%d step=1 +The supplied range exceeds the maximum array size by %d elements: start=0, end=%d, step=1. Calculated size: %d. Maximum size: %d. diff --git a/ext/standard/tests/array/range/range_bug70239_3.phpt b/ext/standard/tests/array/range/range_bug70239_3.phpt index 7099eb1e98cf..6307927438df 100644 --- a/ext/standard/tests/array/range/range_bug70239_3.phpt +++ b/ext/standard/tests/array/range/range_bug70239_3.phpt @@ -9,4 +9,4 @@ try { } ?> --EXPECTF-- -The supplied range exceeds the maximum array size: start=-%d end=0 step=1 +The supplied range exceeds the maximum array size by %d elements: start=-%d, end=0, step=1. Calculated size: %d. Maximum size: %d. diff --git a/ext/standard/tests/array/range/range_inputs_float_small_step_exhaustion.phpt b/ext/standard/tests/array/range/range_inputs_float_small_step_exhaustion.phpt index b00b3142627c..41ae4ef995bf 100644 --- a/ext/standard/tests/array/range/range_inputs_float_small_step_exhaustion.phpt +++ b/ext/standard/tests/array/range/range_inputs_float_small_step_exhaustion.phpt @@ -14,5 +14,5 @@ try { } ?> --EXPECTF-- -The supplied range exceeds the maximum array size: start=0.0 end=100000000000.0 step=0.1 -The supplied range exceeds the maximum array size: start=-%d end=%d step=1 +The supplied range exceeds the maximum array size by %f elements: start=0.0, end=%f, step=0.1. Max size: %d +The supplied range exceeds the maximum array size by %d elements: start=-%d, end=%d, step=1. Calculated size: %d. Maximum size: %d.