xref: /PHP-8.0/ext/ffi/tests/bug78761.phpt (revision 75970077)
1--TEST--
2Bug #78761 (Zend memory heap corruption with preload and casting)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
7if (!extension_loaded('posix')) die('skip POSIX extension not loaded');
8if (posix_geteuid() == 0) die('skip Cannot run test as root.');
9?>
10--INI--
11opcache.enable_cli=1
12opcache.preload={PWD}/bug78761_preload.php
13--FILE--
14<?php
15try {
16    FFI::cast('char[10]', FFI::new('char[1]'));
17} catch (FFI\Exception $ex) {
18    echo $ex->getMessage(), PHP_EOL;
19}
20?>
21--EXPECT--
22attempt to cast to larger type
23