Browse Source

- Fixed memory leak when calling SplFileInfo's constructor twice

pull/12/head
Felipe Pena 15 years ago
parent
commit
af2fc625df
  1. 1
      NEWS
  2. 9
      ext/spl/spl_directory.c
  3. 11
      ext/spl/tests/SplFileInfo_001.phpt

1
NEWS

@ -71,6 +71,7 @@ PHP NEWS
chunksize length line is > 10 bytes). (Ilia) chunksize length line is > 10 bytes). (Ilia)
- SPL - SPL
. Fixed memory leak when calling SplFileInfo's constructor twice. (Felipe)
. Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence) . Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence)
. Fixed bug #61326 (ArrayObject comparison). (Gustavo) . Fixed bug #61326 (ArrayObject comparison). (Gustavo)

9
ext/spl/spl_directory.c

@ -366,6 +366,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) /* {{{ */ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path, int len, int use_copy TSRMLS_DC) /* {{{ */
{ {
char *p1, *p2; char *p1, *p2;
if (intern->file_name) {
efree(intern->file_name);
}
intern->file_name = use_copy ? estrndup(path, len) : path; intern->file_name = use_copy ? estrndup(path, len) : path;
intern->file_name_len = len; intern->file_name_len = len;
@ -386,7 +390,10 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path,
} else { } else {
intern->_path_len = 0; intern->_path_len = 0;
} }
if (intern->_path) {
efree(intern->_path);
}
intern->_path = estrndup(path, intern->_path_len); intern->_path = estrndup(path, intern->_path_len);
} /* }}} */ } /* }}} */

11
ext/spl/tests/SplFileInfo_001.phpt

@ -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…
Cancel
Save