Skip to content

Commit 788475b

Browse files
committed
Revert "INTRODUCE BUG FOR TESTING ASAN"
This reverts commit 523ec89.
1 parent 523ec89 commit 788475b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ext/handlers_httpstreams.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)