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