Skip to content

Commit 31e0e9b

Browse files
committed
[TEST] Name every constructor argument in the new cases
HttpOperation keeps references to its ssl options, headers, body, compression and retry policy. The short constructor form materialises the defaulted ones as temporaries that die at the end of the full expression, and Setup() reads them from inside Send(): the Bazel asan job reported stack-use-after-scope in HttpOperation::Setup() with the frame belonging to the case. RetryPolicyEnabled in this file passes all twelve by name for that reason. The case I patterned on, RetryJitterIsNotSharedAcrossThreads, uses the short form and never calls Send(), so it never sees it. Verified with bazel test --config=asan on the same target: no sanitizer report, and the new cases run. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent 4d3d91e commit 31e0e9b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎ext/test/http/curl_http_test.cc‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,14 @@ TEST_F(BasicCurlHttpTests, ACaCertificateStringIsPassedAsABlob)
521521
http_client::Body body;
522522
http_client::Headers headers;
523523

524+
http_client::Compression compression = http_client::Compression::kNone;
525+
http_client::RetryPolicy retry_policy;
526+
527+
// Every argument is named. The defaulted ones would be temporaries, and the operation keeps
528+
// references to them past the end of this expression.
524529
curl::HttpOperation operation(http_client::Method::Get, "http://127.0.0.1:19000/get/",
525-
ssl_options, &handler, headers, body);
530+
ssl_options, &handler, headers, body, compression, false,
531+
curl::kDefaultHttpConnTimeout, false, false, retry_policy);
526532

527533
ASSERT_EQ(CURLE_OK, operation.Send());
528534
ASSERT_EQ(200, operation.GetResponseCode());

0 commit comments

Comments
 (0)