diff --git a/ext/standard/array.c b/ext/standard/array.c index 13731592d836e..e319c0927916d 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -5846,7 +5846,7 @@ PHP_FUNCTION(array_diff) { zval *args; uint32_t argc, i; - uint32_t num; + uint64_t num; HashTable exclude; zval *value; zend_string *str, *tmp_str, *key; @@ -5936,6 +5936,11 @@ PHP_FUNCTION(array_diff) return; } + if (UNEXPECTED(num >= HT_MAX_SIZE)) { + zend_throw_error(NULL, "The total number of elements must be lower than %u", HT_MAX_SIZE); + RETURN_THROWS(); + } + ZVAL_NULL(&dummy); /* create exclude map */ zend_hash_init(&exclude, num, NULL, NULL, 0);