Skip to content

Commit 501f1a4

Browse files
committed
Error on resource ID space overflow
When more than INT_MAX resource are created, throw a fatal error, rather than reusing already allocated IDs, which will result in assertion failures or crashes down the line. This doesn't fix the fundamental problem, but makes the failure more graceful with an obvious cause. Inspired by https://bugs.php.net/bug.php?id=81399. Closes GH-7428.
1 parent edab9ad commit 501f1a4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Zend/zend_list.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type)
3737
index = zend_hash_next_free_element(&EG(regular_list));
3838
if (index == 0) {
3939
index = 1;
40+
} else if (index == INT_MAX) {
41+
zend_error_noreturn(E_ERROR, "Resource ID space overflow");
4042
}
4143
ZVAL_NEW_RES(&zv, index, ptr, type);
4244
return zend_hash_index_add_new(&EG(regular_list), index, &zv);

0 commit comments

Comments
 (0)