mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
- Fixed memory leak when calling SplFileInfo's constructor twice
This commit is contained in:
parent
b7ae5e0d86
commit
80cb6e56f6
@ -376,6 +376,10 @@ static zend_object_value spl_filesystem_object_clone(zval *zobject TSRMLS_DC)
|
||||
void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path, int len, int use_copy TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
char *p1, *p2;
|
||||
|
||||
if (intern->file_name) {
|
||||
efree(intern->file_name);
|
||||
}
|
||||
|
||||
intern->file_name = use_copy ? estrndup(path, len) : path;
|
||||
intern->file_name_len = len;
|
||||
@ -396,7 +400,10 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path,
|
||||
} else {
|
||||
intern->_path_len = 0;
|
||||
}
|
||||
|
||||
|
||||
if (intern->_path) {
|
||||
efree(intern->_path);
|
||||
}
|
||||
intern->_path = estrndup(path, intern->_path_len);
|
||||
} /* }}} */
|
||||
|
||||
|
11
ext/spl/tests/SplFileInfo_001.phpt
Normal file
11
ext/spl/tests/SplFileInfo_001.phpt
Normal file
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Testing SplFileInfo calling the constructor twice
|
||||
--FILE--
|
||||
<?php
|
||||
$x = new splfileinfo(1);
|
||||
$x->__construct(1);
|
||||
|
||||
echo "done!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
Loading…
Reference in New Issue
Block a user