felipe Sun, 11 Mar 2012 15:42:57 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=324110
Log:
- Fixed memory leak when calling SplFileInfo's constructor twice
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
A php/php-src/branches/PHP_5_3/ext/spl/tests/SplFileInfo_001.phpt
U php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c
A php/php-src/branches/PHP_5_4/ext/spl/tests/SplFileInfo_001.phpt
U php/php-src/trunk/ext/spl/spl_directory.c
A php/php-src/trunk/ext/spl/tests/SplFileInfo_001.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2012-03-11 15:31:19 UTC (rev 324109)
+++ php/php-src/branches/PHP_5_3/NEWS 2012-03-11 15:42:57 UTC (rev 324110)
@@ -71,6 +71,7 @@
chunksize length line is > 10 bytes). (Ilia)
- SPL
+ . Fixed memory leak when calling SplFileInfo's constructor twice. (Felipe)
. Fixed bug #61347 (inconsistent isset behavior of Arrayobject). (Laruence)
. Fixed bug #61326 (ArrayObject comparison). (Gustavo)
Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2012-03-11
15:31:19 UTC (rev 324109)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c 2012-03-11
15:42:57 UTC (rev 324110)
@@ -366,6 +366,10 @@
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;
@@ -386,7 +390,10 @@
} else {
intern->_path_len = 0;
}
-
+
+ if (intern->_path) {
+ efree(intern->_path);
+ }
intern->_path = estrndup(path, intern->_path_len);
} /* }}} */
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/SplFileInfo_001.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/SplFileInfo_001.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/SplFileInfo_001.phpt
2012-03-11 15:42:57 UTC (rev 324110)
@@ -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!
Modified: php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c 2012-03-11
15:31:19 UTC (rev 324109)
+++ php/php-src/branches/PHP_5_4/ext/spl/spl_directory.c 2012-03-11
15:42:57 UTC (rev 324110)
@@ -376,6 +376,10 @@
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 @@
} else {
intern->_path_len = 0;
}
-
+
+ if (intern->_path) {
+ efree(intern->_path);
+ }
intern->_path = estrndup(path, intern->_path_len);
} /* }}} */
Added: php/php-src/branches/PHP_5_4/ext/spl/tests/SplFileInfo_001.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/spl/tests/SplFileInfo_001.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_4/ext/spl/tests/SplFileInfo_001.phpt
2012-03-11 15:42:57 UTC (rev 324110)
@@ -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!
Modified: php/php-src/trunk/ext/spl/spl_directory.c
===================================================================
--- php/php-src/trunk/ext/spl/spl_directory.c 2012-03-11 15:31:19 UTC (rev
324109)
+++ php/php-src/trunk/ext/spl/spl_directory.c 2012-03-11 15:42:57 UTC (rev
324110)
@@ -376,6 +376,10 @@
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 @@
} else {
intern->_path_len = 0;
}
-
+
+ if (intern->_path) {
+ efree(intern->_path);
+ }
intern->_path = estrndup(path, intern->_path_len);
} /* }}} */
Added: php/php-src/trunk/ext/spl/tests/SplFileInfo_001.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/SplFileInfo_001.phpt
(rev 0)
+++ php/php-src/trunk/ext/spl/tests/SplFileInfo_001.phpt 2012-03-11
15:42:57 UTC (rev 324110)
@@ -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!
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php