Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1245)

Unified Diff: webrtc/modules/video_coding/video_packet_buffer_unittest.cc

Issue 2535203002: Fix memory leak in video_coding::PacketBuffer::InsertPacket. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/video_packet_buffer_unittest.cc
diff --git a/webrtc/modules/video_coding/video_packet_buffer_unittest.cc b/webrtc/modules/video_coding/video_packet_buffer_unittest.cc
index a937af61ad8b0564c3ae833535255e19575156f1..4625a5425dbfede355b946ed681ff774f94bc876 100644
--- a/webrtc/modules/video_coding/video_packet_buffer_unittest.cc
+++ b/webrtc/modules/video_coding/video_packet_buffer_unittest.cc
@@ -438,5 +438,27 @@ TEST_F(TestPacketBuffer, FramesAfterClear) {
CheckFrame(9057);
}
+TEST_F(TestPacketBuffer, DontLeakPayloadData) {
+ // NOTE! Any eventual leak is suppose to be detected by valgrind
+ // or any other similar tool.
+ uint8_t* data1 = new uint8_t[5];
+ uint8_t* data2 = new uint8_t[5];
+ uint8_t* data3 = new uint8_t[5];
+ uint8_t* data4 = new uint8_t[5];
+
+ // Expected to free data1 upon PacketBuffer destruction.
+ EXPECT_TRUE(Insert(2, kKeyFrame, kFirst, kNotLast, 5, data1));
+
+ // Expect to free data2 upon insertion.
+ EXPECT_TRUE(Insert(2, kKeyFrame, kFirst, kNotLast, 5, data2));
+
+ // Expect to free data3 upon insertion (old packet).
+ packet_buffer_->ClearTo(1);
+ EXPECT_FALSE(Insert(1, kKeyFrame, kFirst, kNotLast, 5, data3));
+
+ // Expect to free data4 upon insertion (packet buffer is full).
+ EXPECT_FALSE(Insert(2 + kMaxSize, kKeyFrame, kFirst, kNotLast, 5, data4));
+}
+
} // namespace video_coding
} // namespace webrtc
« webrtc/modules/video_coding/packet_buffer.cc ('K') | « webrtc/modules/video_coding/packet_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698