Skip to content

Commit deed65a

Browse files
committed
tree: use php_stream_context_get_default() rather than FG(default_context)
1 parent f796b28 commit deed65a

5 files changed

Lines changed: 8 additions & 14 deletions

File tree

‎ext/hash/hash.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static void php_hash_do_hash(
356356
zend_argument_value_error(2, "must not contain any null bytes");
357357
RETURN_THROWS();
358358
}
359-
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
359+
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, php_stream_context_get_default());
360360
if (!stream) {
361361
/* Stream will report errors opening file */
362362
RETURN_FALSE;
@@ -499,7 +499,7 @@ static void php_hash_do_hash_hmac(
499499
zend_argument_value_error(2, "must not contain any null bytes");
500500
RETURN_THROWS();
501501
}
502-
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
502+
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, php_stream_context_get_default());
503503
if (!stream) {
504504
/* Stream will report errors opening file */
505505
RETURN_FALSE;

‎ext/pdo_pgsql/pgsql_driver.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ void pgsqlCopyFromFile_internal(INTERNAL_FUNCTION_PARAMETERS)
861861
PDO_CONSTRUCT_CHECK;
862862
PDO_DBH_CLEAR_ERR();
863863

864-
stream = php_stream_open_wrapper_ex(filename, "rb", 0, NULL, FG(default_context));
864+
stream = php_stream_open_wrapper_ex(filename, "rb", 0, NULL, php_stream_context_get_default());
865865
if (!stream) {
866866
pdo_pgsql_error_msg(dbh, PGRES_FATAL_ERROR, "Unable to open the file");
867867
PDO_HANDLE_DBH_ERR();
@@ -966,7 +966,7 @@ void pgsqlCopyToFile_internal(INTERNAL_FUNCTION_PARAMETERS)
966966

967967
H = (pdo_pgsql_db_handle *)dbh->driver_data;
968968

969-
stream = php_stream_open_wrapper_ex(filename, "wb", 0, NULL, FG(default_context));
969+
stream = php_stream_open_wrapper_ex(filename, "wb", 0, NULL, php_stream_context_get_default());
970970
if (!stream) {
971971
pdo_pgsql_error_msg(dbh, PGRES_FATAL_ERROR, "Unable to open the file for writing");
972972
PDO_HANDLE_DBH_ERR();

‎ext/spl/spl_directory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_string *
283283
bool skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
284284

285285
intern->type = SPL_FS_DIR;
286-
intern->u.dir.dirp = php_stream_opendir(ZSTR_VAL(path), REPORT_ERRORS, FG(default_context));
286+
intern->u.dir.dirp = php_stream_opendir(ZSTR_VAL(path), REPORT_ERRORS, php_stream_context_get_default());
287287

288288
if (intern->u.dir.dirp) {
289289
/* we prevent potential UAF with conflicting explicit fclose(), relying on the object destructor for this */

‎ext/standard/streamsfuncs.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,10 +1190,7 @@ PHP_FUNCTION(stream_context_get_default)
11901190
Z_PARAM_ARRAY_HT_OR_NULL(params)
11911191
ZEND_PARSE_PARAMETERS_END();
11921192

1193-
if (FG(default_context) == NULL) {
1194-
FG(default_context) = php_stream_context_alloc();
1195-
}
1196-
context = FG(default_context);
1193+
context = php_stream_context_get_default();
11971194

11981195
if (params) {
11991196
if (parse_context_options(context, params) == FAILURE) {
@@ -1233,10 +1230,7 @@ PHP_FUNCTION(stream_context_set_default)
12331230
Z_PARAM_ARRAY_HT(options)
12341231
ZEND_PARSE_PARAMETERS_END();
12351232

1236-
if (FG(default_context) == NULL) {
1237-
FG(default_context) = php_stream_context_alloc();
1238-
}
1239-
context = FG(default_context);
1233+
context = php_stream_context_get_default();
12401234

12411235
if (php_stream_context_options_has_error_settings(options)) {
12421236
zend_value_error("Stream error handling options cannot be set on the default context");

‎main/streams/stream_errors.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ PHPAPI void php_stream_error_operation_end(const php_stream_context *context)
473473
}
474474

475475
if (context == NULL) {
476-
context = FG(default_context);
476+
context = php_stream_context_get_default();
477477
}
478478

479479
php_stream_error_mode error_mode = php_stream_get_error_mode(context);

0 commit comments

Comments
 (0)