Merge branch 'PHP-7.4'

* PHP-7.4:
  Fix #78762: Failing FFI::cast() may leak memory
This commit is contained in:
Christoph M. Becker 2019-10-30 17:22:56 +01:00
commit 9b817264eb
2 changed files with 15 additions and 0 deletions

View File

@ -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) {

View 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