1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 15:08:16 +02:00
Files
archived-php-src/ext/ffi/tests/027.phpt
T
Dmitry Stogov 53fc8ef41d Merge branch 'PHP-7.4'
* PHP-7.4:
  Disable instantiation of zero size FFI\CData objects
  Fix # 79171: heap-buffer-overflow in phar_extract_file
  Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions
  Fix bug #79221 - Null Pointer Dereference in PHP Session Upload Progress
2020-02-17 12:54:11 +03:00

92 lines
2.3 KiB
PHP

--TEST--
FFI 027: Incomplete and variable length arrays
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
ffi.enable=1
--FILE--
<?php
try {
$p = FFI::new("int[*]");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
FFI::cdef("static int (*foo)[*];");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
FFI::cdef("typedef int foo[*];");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
FFI::cdef("static void foo(int[*][*]);");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
var_dump(FFI::sizeof(FFI::new("int[0]")));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
var_dump(FFI::sizeof(FFI::new("int[]")));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]"))));
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
FFI::cdef("struct _x {int a; int b[];};");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
$f = FFI::cdef("typedef int(*foo)[];");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
$f = FFI::cdef("typedef int foo[][2];");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
$f = FFI::cdef("typedef int foo[];");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
try {
$f = FFI::cdef("static int foo(int[]);");
echo "ok\n";
} catch (Throwable $e) {
echo get_class($e) . ": " . $e->getMessage()."\n";
}
?>
--EXPECT--
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
FFI\ParserException: '[*]' not allowed in other than function prototype scope at line 1
ok
FFI\Exception: Cannot instantiate FFI\CData of zero size
FFI\ParserException: '[]' not allowed at line 1
FFI\ParserException: '[]' not allowed at line 1
ok
ok
ok
ok
ok