]> granicus.if.org Git - php/commitdiff
Setup FG(default_context) in RINIT/RSHUTDOWN instead of fg_ctor/fg_dtor.
authorSara Golemon <pollita@php.net>
Wed, 21 May 2003 21:36:51 +0000 (21:36 +0000)
committerSara Golemon <pollita@php.net>
Wed, 21 May 2003 21:36:51 +0000 (21:36 +0000)
Frees context at right time without double freeing.

ext/standard/basic_functions.c
ext/standard/file.c

index edcdabf5c82a555758f5fba918faa92e6918d711..e07012dd27f1a8275f3b87e1c263b4097cb296d0 100644 (file)
@@ -1196,6 +1196,9 @@ PHP_RINIT_FUNCTION(basic)
        /* Reset magic_quotes_runtime */
        PG(magic_quotes_runtime) = INI_BOOL("magic_quotes_runtime");
 
+       /* Setup default context */
+       FG(default_context) = NULL;
+
        return SUCCESS;
 }
 
@@ -1244,6 +1247,11 @@ PHP_RSHUTDOWN_FUNCTION(basic)
                efree(BG(user_filter_map));
                BG(user_filter_map) = NULL;
        }
+
+       /* cleanup any default context that was created */
+       if (FG(default_context)) {
+               php_stream_context_free(FG(default_context));
+       }
        
        return SUCCESS;
 }
index 055e83bd437c1339e02b0f91b1389f756a743615..f31c3718ded7c5877a915ef84a042b1ff7118524 100644 (file)
@@ -137,15 +137,10 @@ static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
        FG(pclose_ret) = 0;
        FG(user_stream_current_filename) = NULL;
        FG(def_chunk_size) = PHP_SOCK_CHUNK_SIZE;
-       FG(default_context) = NULL;
 }
 
 static void file_globals_dtor(php_file_globals *file_globals_p TSRMLS_DC)
 {
-       if (FG(default_context)) {
-               /* This is being automagically freed elsewhere */
-               FG(default_context) = NULL;
-       }
 }