Skip to content

Fix stream_context_create() rejecting an "options" parameter held by reference - #25719

Closed
lacatoire wants to merge 3 commits into
php:PHP-8.4from
lacatoire:fix/standard-context-params-options-reference-8.4
Closed

lacatoire wants to merge 3 commits into
php:PHP-8.4from
lacatoire:fix/standard-context-params-options-reference-8.4

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

stream_context_create() and stream_context_set_params() throw a TypeError when the options element of $params is a reference, although it holds a valid array. parse_context_params() checks the type without dereferencing the zval first.

$options = ['http' => ['method' => 'HEAD']];
$params = ['options' => &$options];
var_dump(stream_context_create(null, $params));

Before: TypeError: Invalid stream/context parameter

After: the context is created with the http options.

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use the deref API rather than the macro

Comment thread ext/standard/streamsfuncs.c Resolved
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Comment thread ext/standard/streamsfuncs.c Resolved
zend_hash_str_find_deref() already dereferences the value.
@LamentXU123

Copy link
Copy Markdown
Member

@devnexen Do you think this is good to go now?

LamentXU123 added a commit that referenced this pull request Nov 28, 2026
* PHP-8.6:
  Fix stream context functions rejecting options held by reference (#25719)
wushanru pushed a commit to wushanru/php-src that referenced this pull request Nov 28, 2026
* PHP-8.4:
  Fix stream context functions rejecting options held by reference (php#25719)
wushanru pushed a commit to wushanru/php-src that referenced this pull request Nov 28, 2026
* PHP-8.5:
  Fix stream context functions rejecting options held by reference (php#25719)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants