File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -466,8 +466,15 @@ ZEND_API zend_coroutine_event_callback_t *zend_async_coroutine_callback_new(
466466static zend_always_inline zend_async_waker_trigger_t * waker_trigger_create (
467467 zend_async_event_t * event , uint32_t initial_capacity )
468468{
469+ ZEND_ASSERT (initial_capacity > 0 );
470+
471+ // Ensure minimum capacity of 2
472+ if (initial_capacity == 1 ) {
473+ initial_capacity = 2 ;
474+ }
475+
469476 size_t total_size = sizeof (zend_async_waker_trigger_t )
470- + ( initial_capacity - 1 ) * sizeof (zend_async_event_callback_t * );
477+ + initial_capacity * sizeof (zend_async_event_callback_t * );
471478 zend_async_waker_trigger_t * trigger = (zend_async_waker_trigger_t * ) emalloc (total_size );
472479
473480 trigger -> length = 0 ;
You can’t perform that action at this time.
0 commit comments