Skip to content

Commit 7974443

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 4a89489 commit 7974443

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
@@ -514,8 +514,14 @@ TEST_F(BasicCurlHttpTests, ACaCertificateStringIsPassedAsABlob)
514514
http_client::Body body;
515515
http_client::Headers headers;
516516

517+
http_client::Compression compression = http_client::Compression::kNone;
518+
http_client::RetryPolicy retry_policy;
519+
520+
// Every argument is named. The defaulted ones would be temporaries, and the operation keeps
521+
// references to them past the end of this expression.
517522
curl::HttpOperation operation(http_client::Method::Get, "http://127.0.0.1:19000/get/",
518-
ssl_options, &handler, headers, body);
523+
ssl_options, &handler, headers, body, compression, false,
524+
curl::kDefaultHttpConnTimeout, false, false, retry_policy);
519525

520526
ASSERT_EQ(CURLE_OK, operation.Send());
521527
ASSERT_EQ(200, operation.GetResponseCode());

0 commit comments

Comments
 (0)