mirror of
https://github.com/php/php-src.git
synced 2025-01-26 13:44:22 +08:00
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #78762: Failing FFI::cast() may leak memory
This commit is contained in:
commit
9b817264eb
@ -3854,6 +3854,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */
|
||||
cdata->ptr = &cdata->ptr_holder;
|
||||
cdata->ptr_holder = old_cdata->ptr;
|
||||
} else if (type->size > old_type->size) {
|
||||
zend_object_release(&cdata->std);
|
||||
zend_throw_error(zend_ffi_exception_ce, "attempt to cast to larger type");
|
||||
return;
|
||||
} else if (ptr != &old_cdata->ptr_holder) {
|
||||
|
14
ext/ffi/tests/bug78762.phpt
Normal file
14
ext/ffi/tests/bug78762.phpt
Normal file
@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Bug #78762 (Failing FFI::cast() may leak memory)
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
FFI::cast('char[10]', FFI::new('char[1]'));
|
||||
} catch (FFI\Exception $ex) {
|
||||
echo $ex->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
attempt to cast to larger type
|
Loading…
Reference in New Issue
Block a user