summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2013-06-25 13:38:50 +0800
committerXinchen Hui <laruence@php.net>2013-06-25 13:38:50 +0800
commit9d9ec2a90e59d939f2281d29dd6b9caed4f14a39 (patch)
tree4bf8b093aecbf948a7768eccb2859696f43970ba
parent0093980fe045ef19fc19d69480d58c5a0e135657 (diff)
parent38eb909d064ecbbf51d5869a629dae91a6ed9dcf (diff)
downloadphp-git-9d9ec2a90e59d939f2281d29dd6b9caed4f14a39.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
-rw-r--r--ext/spl/spl_directory.c6
-rw-r--r--ext/spl/tests/bug61828.phpt11
2 files changed, 17 insertions, 0 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index cf653f6899..0b884b38a3 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -710,6 +710,12 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, long ctor_fla
}
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+ if (intern->_path) {
+ /* object is alreay initialized */
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Directory object is already initialized");
+ return;
+ }
intern->flags = flags;
#ifdef HAVE_GLOB
if (SPL_HAS_FLAG(ctor_flags, DIT_CTOR_GLOB) && strstr(path, "glob://") != path) {
diff --git a/ext/spl/tests/bug61828.phpt b/ext/spl/tests/bug61828.phpt
new file mode 100644
index 0000000000..04d435e6d6
--- /dev/null
+++ b/ext/spl/tests/bug61828.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #61828 (Memleak when calling Directory(Recursive)Iterator/Spl(Temp)FileObject ctor twice)
+--FILE--
+<?php
+$x = new DirectoryIterator('.');
+$x->__construct('/tmp');
+echo "Okey";
+?>
+--EXPECTF--
+Warning: DirectoryIterator::__construct(): Directory object is already initialized in %sbug61828.php on line 3
+Okey