Skip to content

Commit 2ab2e15

Browse files
committed
* UNIX: fix PHP_FUNCTION(Async_protect)
1 parent e02e307 commit 2ab2e15

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

async.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include "zend_exceptions.h"
18+
#include "zend_closures.h"
1819
#ifdef HAVE_CONFIG_H
1920
#include <config.h>
2021
#endif
@@ -142,10 +143,10 @@ PHP_FUNCTION(Async_suspend)
142143

143144
PHP_FUNCTION(Async_protect)
144145
{
145-
zval *closure;
146+
zend_object *closure;
146147

147148
ZEND_PARSE_PARAMETERS_START(1, 1)
148-
Z_PARAM_OBJECT(closure)
149+
Z_PARAM_OBJ_OF_CLASS(closure, zend_ce_closure)
149150
ZEND_PARSE_PARAMETERS_END();
150151

151152
zend_coroutine_t *coroutine = ZEND_ASYNC_CURRENT_COROUTINE;
@@ -159,7 +160,10 @@ PHP_FUNCTION(Async_protect)
159160
zval result;
160161
ZVAL_UNDEF(&result);
161162

162-
if (UNEXPECTED(call_user_function(NULL, NULL, closure, &result, 0, NULL) == FAILURE)) {
163+
zval closure_zval;
164+
ZVAL_OBJ(&closure_zval, closure);
165+
166+
if (UNEXPECTED(call_user_function(NULL, NULL, &closure_zval, &result, 0, NULL) == FAILURE)) {
163167
zend_throw_error(NULL, "Failed to call finally handler in finished coroutine");
164168
zval_ptr_dtor(&result);
165169
}

0 commit comments

Comments
 (0)