xref: /php-src/ext/ffi/tests/035.phpt (revision 4acf0084)
1--TEST--
2FFI 035: FFI::cdef()->new() not-owned
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9$p = FFI::cdef()->new("uint16_t[2]", false);
10var_dump($p);
11
12FFI::free($p);
13try {
14    var_dump($p);
15} catch (Throwable $e) {
16    echo get_class($e) . ": " . $e->getMessage()."\n";
17}
18?>
19--EXPECTF--
20object(FFI\CData:uint16_t[2])#%d (2) {
21  [0]=>
22  int(0)
23  [1]=>
24  int(0)
25}
26object(FFI\CData:uint16_t[2])#%d (0) {
27}
28FFI\Exception: Use after free()
29