Fix use-after-free in QuicConnectionTest

PiperOrigin-RevId: 321605881
Change-Id: I2868e3c309d7825a545cad3754b3ac83cb28ae62
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index de7e450..e637ad2 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -11398,7 +11398,8 @@
                            std::make_unique<TaggingEncrypter>(0x01));
   connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
   // Send INITIAL 1.
-  connection_.SendCryptoDataWithString(std::string(512, 'a'), 0,
+  std::string initial_crypto_data(512, 'a');
+  connection_.SendCryptoDataWithString(initial_crypto_data, 0,
                                        ENCRYPTION_INITIAL);
   ASSERT_TRUE(connection_.sent_packet_manager()
                   .GetRetransmissionTime()
@@ -11415,7 +11416,8 @@
   } else {
     EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1);
   }
-  connection_.SendCryptoDataWithString(std::string(1024, 'a'), 0,
+  std::string handshake_crypto_data(1024, 'a');
+  connection_.SendCryptoDataWithString(handshake_crypto_data, 0,
                                        ENCRYPTION_HANDSHAKE);
 
   // INITIAL 1 gets lost and PTO fires.