return &EG(uninitialized_zval);
}
- zend_tmp_string_release(tmp_var_name);
-
if (sym->kind == ZEND_FFI_SYM_VAR) {
zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const, 0);
+ } else if (sym->kind == ZEND_FFI_SYM_FUNC) {
+ zend_ffi_cdata *cdata;
+ zend_ffi_type *new_type = emalloc(sizeof(zend_ffi_type));
+
+ new_type->kind = ZEND_FFI_TYPE_POINTER;
+ new_type->attr = 0;
+ new_type->size = sizeof(void*);
+ new_type->align = _Alignof(void*);
+ new_type->pointer.type = ZEND_FFI_TYPE(sym->type);
+
+ cdata = emalloc(sizeof(zend_ffi_cdata));
+ zend_ffi_object_init(&cdata->std, zend_ffi_cdata_ce);
+ cdata->std.handlers = &zend_ffi_cdata_handlers;
+ cdata->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type);
+ cdata->flags = ZEND_FFI_FLAG_CONST;
+ cdata->ptr_holder = sym->addr;
+ cdata->ptr = &cdata->ptr_holder;
+ ZVAL_OBJ(rv, &cdata->std);
} else {
ZVAL_LONG(rv, sym->value);
}