Explicitly initialize ecn_codepoint in the ReceivedPacketInfo constructor.
PiperOrigin-RevId: 501911452
diff --git a/quiche/quic/core/quic_connection.h b/quiche/quic/core/quic_connection.h
index 9fb1aaa..7f58c5e 100644
--- a/quiche/quic/core/quic_connection.h
+++ b/quiche/quic/core/quic_connection.h
@@ -1498,7 +1498,7 @@
EncryptionLevel decrypted_level = ENCRYPTION_INITIAL;
QuicPacketHeader header;
absl::InlinedVector<QuicFrameType, 1> frames;
- QuicEcnCodepoint ecn_codepoint;
+ QuicEcnCodepoint ecn_codepoint = ECN_NOT_ECT;
};
QUIC_EXPORT_PRIVATE friend std::ostream& operator<<(
diff --git a/quiche/quic/core/quic_connection_test.cc b/quiche/quic/core/quic_connection_test.cc
index 98027d4..8fb5f78 100644
--- a/quiche/quic/core/quic_connection_test.cc
+++ b/quiche/quic/core/quic_connection_test.cc
@@ -16708,6 +16708,10 @@
connection_.SupportsMultiplePacketNumberSpaces() ? 1 : 2);
}
+TEST_P(QuicConnectionTest, ReceivedPacketInfoDefaults) {
+ EXPECT_TRUE(QuicConnectionPeer::TestLastReceivedPacketInfoDefaults());
+}
+
} // namespace
} // namespace test
} // namespace quic
diff --git a/quiche/quic/test_tools/quic_connection_peer.cc b/quiche/quic/test_tools/quic_connection_peer.cc
index ad58d9c..3d63682 100644
--- a/quiche/quic/test_tools/quic_connection_peer.cc
+++ b/quiche/quic/test_tools/quic_connection_peer.cc
@@ -582,5 +582,22 @@
return &connection->peer_ack_ecn_counts_[packet_number_space];
}
+// static
+bool QuicConnectionPeer::TestLastReceivedPacketInfoDefaults() {
+ QuicConnection::ReceivedPacketInfo info{QuicTime::Zero()};
+ return info.destination_address == QuicSocketAddress() &&
+ info.source_address == QuicSocketAddress() &&
+ info.receipt_time == QuicTime::Zero() &&
+ !info.received_bytes_counted && info.length == 0 &&
+ info.destination_connection_id == QuicConnectionId() &&
+ !info.decrypted && info.decrypted_level == ENCRYPTION_INITIAL &&
+ // There's no simple way to compare all the values of QuicPacketHeader.
+ info.frames.empty() && info.ecn_codepoint == ECN_NOT_ECT &&
+ // If the condition below fails, the contents of ReceivedPacketInfo
+ // have changed. Please add the relevant conditions and update the
+ // length below.
+ sizeof(QuicConnection::ReceivedPacketInfo) == 256;
+}
+
} // namespace test
} // namespace quic
diff --git a/quiche/quic/test_tools/quic_connection_peer.h b/quiche/quic/test_tools/quic_connection_peer.h
index fbdedb3..330be03 100644
--- a/quiche/quic/test_tools/quic_connection_peer.h
+++ b/quiche/quic/test_tools/quic_connection_peer.h
@@ -239,6 +239,8 @@
static QuicEcnCounts* GetEcnCounts(QuicConnection* connection,
PacketNumberSpace packet_number_space);
+
+ static bool TestLastReceivedPacketInfoDefaults();
};
} // namespace test