tony2001 Mon May 16 04:37:15 2005 EDT
Modified files:
/php-src/main main.c php_streams.h
/php-src/main/streams streams.c
/php-src/ext/standard basic_functions.c
Log:
fix bugs #32742 (segmentation fault when the stream with a wrapper is not
closed),
#32171 (Userspace stream wrapper crashes PHP)
http://cvs.php.net/diff.php/php-src/main/main.c?r1=1.626&r2=1.627&ty=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.626 php-src/main/main.c:1.627
--- php-src/main/main.c:1.626 Thu Apr 28 03:50:53 2005
+++ php-src/main/main.c Mon May 16 04:37:08 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.626 2005/04/28 07:50:53 sniper Exp $ */
+/* $Id: main.c,v 1.627 2005/05/16 08:37:08 tony2001 Exp $ */
/* {{{ includes
*/
@@ -1160,6 +1160,10 @@
} zend_end_try();
zend_try {
+ php_shutdown_stream_hashes(TSRMLS_C);
+ } zend_end_try();
+
+ zend_try {
shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC);
} zend_end_try();
@@ -1234,12 +1238,17 @@
sapi_deactivate(TSRMLS_C);
} zend_end_try();
- /* 10. Free Willy (here be crashes) */
+ /* 10. Destroy stream hashes */
+ zend_try {
+ php_shutdown_stream_hashes(TSRMLS_C);
+ } zend_end_try();
+
+ /* 11. Free Willy (here be crashes) */
zend_try {
shutdown_memory_manager(CG(unclean_shutdown) ||
!report_memleaks, 0 TSRMLS_CC);
} zend_end_try();
- /* 11. Reset max_execution_time */
+ /* 12. Reset max_execution_time */
zend_try {
zend_unset_timeout(TSRMLS_C);
} zend_end_try();
http://cvs.php.net/diff.php/php-src/main/php_streams.h?r1=1.101&r2=1.102&ty=u
Index: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.101 php-src/main/php_streams.h:1.102
--- php-src/main/php_streams.h:1.101 Mon Feb 21 19:24:13 2005
+++ php-src/main/php_streams.h Mon May 16 04:37:10 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_streams.h,v 1.101 2005/02/22 00:24:13 iliaa Exp $ */
+/* $Id: php_streams.h,v 1.102 2005/05/16 08:37:10 tony2001 Exp $ */
#ifndef PHP_STREAMS_H
#define PHP_STREAMS_H
@@ -502,6 +502,7 @@
int php_init_stream_wrappers(int module_number TSRMLS_DC);
int php_shutdown_stream_wrappers(int module_number TSRMLS_DC);
+void php_shutdown_stream_hashes(TSRMLS_D);
PHP_RSHUTDOWN_FUNCTION(streams);
BEGIN_EXTERN_C()
http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.77&r2=1.78&ty=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.77 php-src/main/streams/streams.c:1.78
--- php-src/main/streams/streams.c:1.77 Fri Apr 29 15:01:33 2005
+++ php-src/main/streams/streams.c Mon May 16 04:37:13 2005
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.77 2005/04/29 19:01:33 iliaa Exp $ */
+/* $Id: streams.c,v 1.78 2005/05/16 08:37:13 tony2001 Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -1378,6 +1378,21 @@
FG(pclose_ret) = php_stream_free(stream, PHP_STREAM_FREE_CLOSE |
PHP_STREAM_FREE_RSRC_DTOR);
}
+void php_shutdown_stream_hashes(TSRMLS_D)
+{
+ if (FG(stream_wrappers)) {
+ zend_hash_destroy(FG(stream_wrappers));
+ efree(FG(stream_wrappers));
+ FG(stream_wrappers) = NULL;
+ }
+
+ if (FG(stream_filters)) {
+ zend_hash_destroy(FG(stream_filters));
+ efree(FG(stream_filters));
+ FG(stream_filters) = NULL;
+ }
+}
+
int php_init_stream_wrappers(int module_number TSRMLS_DC)
{
le_stream =
zend_register_list_destructors_ex(stream_resource_regular_dtor, NULL, "stream",
module_number);
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.716&r2=1.717&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.716
php-src/ext/standard/basic_functions.c:1.717
--- php-src/ext/standard/basic_functions.c:1.716 Fri May 13 06:11:17 2005
+++ php-src/ext/standard/basic_functions.c Mon May 16 04:37:14 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.716 2005/05/13 10:11:17 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.717 2005/05/16 08:37:14 tony2001 Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -1219,18 +1219,11 @@
}
STR_FREE(BG(locale_string));
- if (FG(stream_wrappers)) {
- zend_hash_destroy(FG(stream_wrappers));
- efree(FG(stream_wrappers));
- FG(stream_wrappers) = NULL;
- }
-
- if (FG(stream_filters)) {
- zend_hash_destroy(FG(stream_filters));
- efree(FG(stream_filters));
- FG(stream_filters) = NULL;
- }
-
+ /*
+ FG(stream_wrappers) and FG(stream_filters) are destroyed
+ during php_request_shutdown()
+ */
+
PHP_RSHUTDOWN(filestat)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
#ifdef HAVE_SYSLOG_H
PHP_RSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php