Add memory safety guard for QuicFrame
The current memory model for QuicFrame is error-prone in that the owner of an array of QuicFrames is responsible for deleting non-inlined frames. This CL adds a check in debug and asan builds that will ensure that we crash if we accidentally attempt to delete an ACK frame that is owned by the QuicReceivedPacketManager.
Debug-only change
PiperOrigin-RevId: 328649792
Change-Id: I419cec433393d9f978dffc7f4f54e60c5293fc05
diff --git a/quic/core/quic_received_packet_manager.cc b/quic/core/quic_received_packet_manager.cc
index 9cc6c29..539cdce 100644
--- a/quic/core/quic_received_packet_manager.cc
+++ b/quic/core/quic_received_packet_manager.cc
@@ -189,7 +189,13 @@
}
}
+#if QUIC_FRAME_DEBUG
+ QuicFrame frame = QuicFrame(&ack_frame_);
+ frame.delete_forbidden = true;
+ return frame;
+#else // QUIC_FRAME_DEBUG
return QuicFrame(&ack_frame_);
+#endif // QUIC_FRAME_DEBUG
}
void QuicReceivedPacketManager::DontWaitForPacketsBefore(