Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
}

switch (type->kind) {
case ZEND_FFI_TYPE_VOID:
return NULL;
case ZEND_FFI_TYPE_BOOL:
case ZEND_FFI_TYPE_CHAR:
case ZEND_FFI_TYPE_ENUM:
Expand Down
25 changes: 25 additions & 0 deletions ext/ffi/tests/gh10568.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
GH-10568 (Assertion failure when var_dump'ing void FFI result)
--EXTENSIONS--
ffi
--SKIPIF--
<?php
try {
$libc = FFI::cdef("void strlen(const char *s);", "libc.so.6");
} catch (Throwable $_) {
die('skip libc.so.6 not available');
}
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch (Throwable $_) {
die('skip libc.so.6 not available');
}
} catch (Throwable) {
die('skip libc.so.6 not available');
}

You can omit the variable as of PHP 8.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll wait for other reviews to come in and then I'll update this

?>
--INI--
ffi.enable=1
--FILE--
<?php
// Yes, I know that strlen does not return void, but I need a simple & portable test case.
$libc = FFI::cdef("void strlen(const char *s);", "libc.so.6");
var_dump($libc->strlen("abc"));
?>
DONE
--EXPECT--
object(FFI\CData:void)#2 (0) {
}
DONE