Fix a memory leak in InitializeAndCheckForTlsPskFailure test helper If we switch EXPECT_QUIC_BUG to use EXPECT_DCHECK_DEATH in the Chromium implementation, `client_writer_` gets leaked: https://ci.chromium.org/ui/p/chromium/builders/try/linux_chromium_asan_rel_ng/2009331/overview My mind is not completely made up about whether we should actually switch EXPECT_QUIC_BUG to use EXPECT_DCHECK_DEATH, but at least this change makes it so that we could. PiperOrigin-RevId: 651757108
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc index 4e46693..b7dd0ec 100644 --- a/quiche/quic/core/http/end_to_end_test.cc +++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -935,10 +935,17 @@ // successfully. pre_shared_key_client_ = ""; pre_shared_key_server_ = ""; + StopServer(); server_writer_ = new PacketDroppingTestWriter(); StartServer(); - client_writer_ = new PacketDroppingTestWriter(); + + if (client_) { + // If `client_` is populated it means that the `CreateClientWithWriter()` + // call above ran in-process, in which case `client_` owns + // `client_writer_` and we need to create a new one. + client_writer_ = new PacketDroppingTestWriter(); + } CreateClientWithWriter(); }