Skip to content

Commit d395cdb

Browse files
committed
Check for exceeding array size limits
1 parent 024528c commit d395cdb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ext/collections/collections_deque.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ PHP_METHOD(Collections_Deque, toArray)
767767
if (!len) {
768768
RETURN_EMPTY_ARRAY();
769769
}
770+
if (UNEXPECTED(len >= HT_MAX_SIZE)) {
771+
/* This would take 32GB of memory in 64-bit builds and 1GB in 32-bit builds. (16 bytes per zval) */
772+
zend_throw_exception(spl_ce_RuntimeException, "Cannot convert Deque to an array, this exceeds the maximum array size", 0);
773+
RETURN_THROWS();
774+
}
770775
RETURN_ARR(collections_deque_to_new_array(&intern->array));
771776
}
772777

0 commit comments

Comments
 (0)