com php-src: Fixed segfault (invalid free handling): ext/spl/spl_directory.c ext/spl/spl_directory.h
| From: | Dmitry Stogov | Date: | Sun, 16 Mar 2014 14:05:38 +0000 |
| Subject: | com php-src: Fixed segfault (invalid free handling): ext/spl/spl_directory.c ext/spl/spl_directory.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77631@lists.php.net to get a copy of this message | ||
Commit: b78bbe93ca8531194de8c9378b711ba1373ea8b2
Author: Xinchen Hui <laruence@gmail.com> Sun, 16 Mar 2014 22:05:38 +0800
Parents: 5ec42e9dec966e49584a2532727998532e61b9a1
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b78bbe93ca8531194de8c9378b711ba1373ea8b2
Log:
Fixed segfault (invalid free handling)
Changed paths:
M ext/spl/spl_directory.c
M ext/spl/spl_directory.h
Diff:
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 6acfc59..b86994c 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -123,9 +123,9 @@ static void spl_filesystem_object_free_storage(zend_object *object TSRMLS_DC) /*
break;
}
- //???if (intern->it) {
- //zend_iterator_dtor(intern->it TSRMLS_CC);
- //}
+ if (intern->it) {
+ //????zend_iterator_dtor(&intern->it->intern);
+ }
efree(intern);
} /* }}} */
@@ -1661,7 +1661,7 @@ static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC)
zval *object = &iterator->intern..data;
zval_ptr_dtor(object);
}
- efree(iter);
+ efree(iterator);
/* Otherwise we were called from the owning object free storage handler as
* it sets
* iterator->intern.data to NULL..
@@ -1738,6 +1738,7 @@ static void spl_filesystem_tree_it_dtor(zend_object_iterator *iter TSRMLS_DC)
ZVAL_UNDEF(&iterator->current);
}
}
+ efree(iter);
}
/* }}} */
@@ -2983,8 +2984,8 @@ PHP_MINIT_FUNCTION(spl_directory)
{
REGISTER_SPL_STD_CLASS_EX(SplFileInfo, spl_filesystem_object_new, spl_SplFileInfo_functions);
memcpy(&spl_filesystem_object_handlers, zend_get_std_object_handlers(),
sizeof(zend_object_handlers));
- spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
- spl_filesystem_object_handlers.cast_object = spl_filesystem_object_cast;
+ spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
+ spl_filesystem_object_handlers.cast_object = spl_filesystem_object_cast;
spl_filesystem_object_handlers.get_debug_info = spl_filesystem_object_get_debug_info;
spl_filesystem_object_handlers.dtor_obj = zend_objects_destroy_object;
spl_filesystem_object_handlers.free_obj = spl_filesystem_object_free_storage;
diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h
index bfab801..3276d51 100644
--- a/ext/spl/spl_directory..h
+++ b/ext/spl/spl_directory.h
@@ -114,10 +114,6 @@ static inline spl_filesystem_object *spl_filesystem_from_obj(zend_object *obj)
/
static inline spl_filesystem_iterator* spl_filesystem_object_to_iterator(spl_filesystem_object *obj
TSRMLS_DC)
{
- if (obj->it) {
- zend_iterator_dtor(&obj->it->intern TSRMLS_CC);
- }
-
obj->it = ecalloc(1, sizeof(spl_filesystem_iterator));
obj->it->object = (void *)obj;
zend_iterator_init(&obj->it->intern TSRMLS_CC);