File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,10 +89,12 @@ static php_stream *dd_stream_opener(
8989 if (http_context_zv && Z_TYPE_P (http_context_zv ) == IS_ARRAY ) {
9090 zval * method_zv = zend_hash_str_find (Z_ARRVAL_P (http_context_zv ), "method" , sizeof ("method" ) - 1 );
9191 if (method_zv && Z_TYPE_P (method_zv ) == IS_STRING ) {
92- // TEMPORARY (for ASAN validation): do not take an extra ref to the method string.
93- // This is intentionally unsafe and is expected to produce ASAN issues if the stream context
94- // is freed before span serialization reads the meta value.
95- zend_hash_str_update (meta , ZEND_STRL ("http.method" ), method_zv );
92+ // `zend_hash_str_update()` moves the zval payload into the hashtable without adding a ref.
93+ // `method_zv` is owned by the stream context options array, so we must add a ref (via ZVAL_COPY)
94+ // to avoid leaving span meta with a dangling zend_string once the options array is destroyed.
95+ zval method_copy ;
96+ ZVAL_COPY (& method_copy , method_zv );
97+ zend_hash_str_update (meta , ZEND_STRL ("http.method" ), & method_copy );
9698 }
9799 }
98100
You can’t perform that action at this time.
0 commit comments