Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/standard/streamsfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ static zend_result parse_context_params(php_stream_context *context, HashTable *
context->notifier->dtor = user_space_stream_notifier_dtor;
}
if (NULL != (tmp = zend_hash_str_find(params, "options", sizeof("options")-1))) {
ZVAL_DEREF(tmp);
if (Z_TYPE_P(tmp) == IS_ARRAY) {
return parse_context_options(context, Z_ARRVAL_P(tmp));
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--TEST--
stream_context_create() and stream_context_set_params() accept an "options" element held by reference
--FILE--
<?php

$options = ['http' => ['method' => 'HEAD']];
$params = ['options' => &$options];

try {
$context = stream_context_create(null, $params);
var_dump(stream_context_get_options($context));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

$context = stream_context_create();
try {
var_dump(stream_context_set_params($context, $params));
var_dump(stream_context_get_options($context));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

$invalid = 'not an array';
try {
stream_context_create(null, ['options' => &$invalid]);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
array(1) {
["http"]=>
array(1) {
["method"]=>
string(4) "HEAD"
}
}
bool(true)
array(1) {
["http"]=>
array(1) {
["method"]=>
string(4) "HEAD"
}
}
TypeError: Invalid stream/context parameter
Loading