Skip to content

Commit 2abb585

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix assertion failure when var_dump'ing void FFI result (php#10568)
2 parents 9c48f1d + cec528d commit 2abb585

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
@@ -2038,6 +2038,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp)
20382038
}
20392039

20402040
switch (type->kind) {
2041+
case ZEND_FFI_TYPE_VOID:
2042+
return NULL;
20412043
case ZEND_FFI_TYPE_BOOL:
20422044
case ZEND_FFI_TYPE_CHAR:
20432045
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)