mirror of
https://github.com/php/php-src.git
synced 2026-04-21 15:08:16 +02:00
- Fixed memory leak when calling the Finfo constructor twice
This commit is contained in:
@@ -289,6 +289,16 @@ PHP_FUNCTION(finfo_open)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lp", &options, &file, &file_len) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (object) {
|
||||
struct finfo_object *finfo_obj = (struct finfo_object*)zend_object_store_get_object(object TSRMLS_CC);
|
||||
|
||||
if (finfo_obj->ptr) {
|
||||
magic_close(finfo_obj->ptr->magic);
|
||||
efree(finfo_obj->ptr);
|
||||
finfo_obj->ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_len == 0) {
|
||||
file = NULL;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
FileInfo - Calling the constructor twice
|
||||
--SKIPIF--
|
||||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$x = new finfo;
|
||||
$x->finfo();
|
||||
|
||||
echo "done!\n";
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
done!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user