]> granicus.if.org Git - php/commitdiff
MFH: fix bug #32742 (segmentation fault when the stream with a wrapper is not closed)
authorAntony Dovgal <tony2001@php.net>
Mon, 16 May 2005 08:55:31 +0000 (08:55 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 16 May 2005 08:55:31 +0000 (08:55 +0000)
NEWS
ext/standard/basic_functions.c
main/main.c
main/php_streams.h
main/streams.c

diff --git a/NEWS b/NEWS
index e19846bdaf382cdc37ad6fce7a72b23fd89cea0d..1056567d516684e5ee070c3dcdedfd2dca019fc1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP 4                                                                      NEWS
 - Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). (Ilia)
 - Fixed bug #32802 (General cookie overrides more specific cookie). (Ilia)
 - Fixed bugs #32800, #32830 (ext/odbc: Problems with 64bit systems). (Jani)
+- Fixed bug #32742 (segmentation fault when the stream with a wrapper 
+  is not closed). (Tony, Dmitry)
 - Fixed bug #32730 (ext/crack.c fails to compile with cracklib-2.8.3). (Jani)
 - Fixed bug #32670 (foreach() does not issue warning on unset array arg). (Ilia)
 - Fixed bug #32699 (pg_affected_rows() was defined when it was not available).
index 60ea17b70b24de0b716eee9b4ac365afeef8e15f..c995c1a8faf6b52282320ca83c413b8cb349f4ea 100644 (file)
@@ -1239,11 +1239,10 @@ PHP_RSHUTDOWN_FUNCTION(basic)
        }
        STR_FREE(BG(locale_string));
 
-       if (FG(stream_wrappers)) {
-               zend_hash_destroy(FG(stream_wrappers));
-               efree(FG(stream_wrappers));
-               FG(stream_wrappers) = NULL;
-       }
+       /*
+        FG(stream_wrappers) are destroyed
+        during php_request_shutdown()
+        */
 
        PHP_RSHUTDOWN(fsock) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
        PHP_RSHUTDOWN(filestat) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
index 559e85f70ab81c1008a343b6ad9129041a0e34dc..8db03b401bd8011366e02963e6036feb17f386f2 100644 (file)
@@ -1000,6 +1000,10 @@ void php_request_shutdown(void *dummy)
                sapi_deactivate(TSRMLS_C);
        } 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();
index 52c6f8d8862844940008bdce50641e35a2ddbbe9..5b7726c39ae4cead018213ed73bfc899a90a839a 100755 (executable)
@@ -526,6 +526,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
 
 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);
 
 PHPAPI int php_register_url_stream_wrapper(char *protocol, php_stream_wrapper *wrapper TSRMLS_DC);
index 5ff2fed5afea03649746f9a01e29131561c13cd5..fe3575b8059917a9cbff13cacb9fdd010aa0467c 100755 (executable)
@@ -2330,6 +2330,15 @@ static void stream_resource_persistent_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC
        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;
+       }
+}
+
 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);