Browse Source

Setup FG(default_context) in RINIT/RSHUTDOWN instead of fg_ctor/fg_dtor.

Frees context at right time without double freeing.
migration/unlabaled-1.3.2
Sara Golemon 23 years ago
parent
commit
af5e2af752
  1. 8
      ext/standard/basic_functions.c
  2. 5
      ext/standard/file.c

8
ext/standard/basic_functions.c

@ -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;
}

5
ext/standard/file.c

@ -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;
}
}

Loading…
Cancel
Save