- Fixed memory leak when calling the Finfo constructor twice

This commit is contained in:
Felipe Pena 2011-11-23 01:20:49 +00:00
parent c446440235
commit b6137f4cb1
3 changed files with 28 additions and 0 deletions

1
NEWS
View File

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

View File

@ -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;

View 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!