File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ PHP NEWS
1818- FFI:
1919 . Fixed bug #78716 (Function name mangling is wrong for some parameter
2020 types). (cmb)
21+ . Fixed bug #78762 (Failing FFI::cast() may leak memory). (cmb)
2122 . Implement FR #78270 (Support __vectorcall convention with FFI). (cmb)
2223
2324- FPM:
Original file line number Diff line number Diff line change @@ -3882,6 +3882,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */
38823882cdata -> ptr = & cdata -> ptr_holder ;
38833883cdata -> ptr_holder = old_cdata -> ptr ;
38843884} else if (type -> size > old_type -> size ) {
3885+ zend_object_release (& cdata -> std );
38853886zend_throw_error (zend_ffi_exception_ce , "attempt to cast to larger type" );
38863887return ;
38873888} else if (ptr != & old_cdata -> ptr_holder ) {
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug #78762 (Failing FFI::cast() may leak memory)
3+ --SKIPIF--
4+ <?php require_once ('skipif.inc ' ); ?>
5+ --FILE--
6+ <?php
7+ try {
8+ FFI ::cast ('char[10] ' , FFI ::new ('char[1] ' ));
9+ } catch (FFI \Exception $ ex ) {
10+ echo $ ex ->getMessage (), PHP_EOL ;
11+ }
12+ ?>
13+ --EXPECT--
14+ attempt to cast to larger type
You can’t perform that action at this time.
0 commit comments