Skip to content

Commit 1a5fc6e

Browse files
authored
Fix assertion failure when var_dump'ing void FFI result (#10568)
1 parent 28d68f5 commit 1a5fc6e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ext/ffi/ffi.c

+2
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
19821982
}
19831983

19841984
switch (type->kind) {
1985+
case ZEND_FFI_TYPE_VOID:
1986+
return NULL;
19851987
case ZEND_FFI_TYPE_BOOL:
19861988
case ZEND_FFI_TYPE_CHAR:
19871989
case ZEND_FFI_TYPE_ENUM:

ext/ffi/tests/gh10568.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-10568 (Assertion failure when var_dump'ing void FFI result)
3+
--EXTENSIONS--
4+
ffi
5+
--SKIPIF--
6+
<?php
7+
try {
8+
$libc = FFI::cdef("void strlen(const char *s);", "libc.so.6");
9+
} catch (Throwable $_) {
10+
die('skip libc.so.6 not available');
11+
}
12+
?>
13+
--INI--
14+
ffi.enable=1
15+
--FILE--
16+
<?php
17+
// Yes, I know that strlen does not return void, but I need a simple & portable test case.
18+
$libc = FFI::cdef("void strlen(const char *s);", "libc.so.6");
19+
var_dump($libc->strlen("abc"));
20+
?>
21+
DONE
22+
--EXPECT--
23+
object(FFI\CData:void)#2 (0) {
24+
}
25+
DONE

0 commit comments

Comments
 (0)