Skip to content

Commit 71b1fdc

Browse files
committed
add tests for field access on non-struct and cdef resolution failure.
1 parent 3536b09 commit 71b1fdc

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

ext/ffi/tests/gh14286_2.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
GH-14286 (ffi enum type (when enum has no name) make memory leak)
33
--EXTENSIONS--
44
ffi
5-
--SKIPIF--
6-
<?php
7-
if (PHP_DEBUG || getenv('SKIP_ASAN')) die("xfail: FFI cleanup after parser error is not implemented");
8-
?>
95
--INI--
106
ffi.enable=1
117
--FILE--
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GH-18629 (FFI::cdef() leaks on function resolution failure)
3+
--EXTENSIONS--
4+
ffi
5+
--INI--
6+
ffi.enable=1
7+
--FILE--
8+
<?php
9+
try {
10+
$ffi = FFI::cdef("void nonexistent_ffi_test_func(void);");
11+
} catch (\FFI\Exception $e) {
12+
echo $e->getMessage() . "\n";
13+
}
14+
?>
15+
--EXPECT--
16+
Failed resolving C function 'nonexistent_ffi_test_func'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-18629 (Read field of non C struct/union)
3+
--EXTENSIONS--
4+
ffi
5+
--INI--
6+
ffi.enable=1
7+
--FILE--
8+
<?php
9+
$x = FFI::cdef()->new("int*");
10+
try {
11+
$y = $x->foo;
12+
} catch (\FFI\Exception $e) {
13+
echo $e->getMessage() . "\n";
14+
}
15+
?>
16+
--EXPECT--
17+
Attempt to read field 'foo' of non C struct/union

0 commit comments

Comments
 (0)