mirror of
https://github.com/php/php-src.git
synced 2025-01-22 03:34:19 +08:00
- Fixed memory leak when calling the Finfo constructor twice
This commit is contained in:
parent
c446440235
commit
b6137f4cb1
1
NEWS
1
NEWS
@ -30,6 +30,7 @@ PHP NEWS
|
||||
|
||||
- Fileinfo:
|
||||
. Fixed possible memory leak in finfo_open(). (Felipe)
|
||||
. Fixed memory leak when calling the Finfo constructor twice. (Felipe)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #60192 (SegFault when Collator not constructed
|
||||
|
@ -290,6 +290,16 @@ PHP_FUNCTION(finfo_open)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &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;
|
||||
|
17
ext/fileinfo/tests/finfo_open_002.phpt
Normal file
17
ext/fileinfo/tests/finfo_open_002.phpt
Normal file
@ -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!
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user