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

Unified Diff: webrtc/modules/video_coding/packet_buffer.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
« no previous file with comments | « no previous file | webrtc/modules/video_coding/video_packet_buffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/packet_buffer.cc
diff --git a/webrtc/modules/video_coding/packet_buffer.cc b/webrtc/modules/video_coding/packet_buffer.cc
index c9d787b6e66184b0f1c0690227d5743397d5c54b..fe211e0044b4e718242e9fa365e6331a8dcb41dd 100644
--- a/webrtc/modules/video_coding/packet_buffer.cc
+++ b/webrtc/modules/video_coding/packet_buffer.cc
@@ -70,16 +70,20 @@ bool PacketBuffer::InsertPacket(const VCMPacket& packet) {
} else if (AheadOf(first_seq_num_, seq_num)) {
// If we have explicitly cleared past this packet then it's old,
// don't insert it.
- if (is_cleared_to_first_seq_num_)
+ if (is_cleared_to_first_seq_num_) {
+ delete[] packet.dataPtr;
nisse-webrtc 2016/11/29 11:59:30 Ownership looks a bit confused here. Argument is a
philipel 2016/11/29 12:28:45 You are absolutely right, so I went for option 2 (
return false;
+ }
first_seq_num_ = seq_num;
}
if (sequence_buffer_[index].used) {
- // Duplicate packet, do nothing.
- if (data_buffer_[index].seqNum == packet.seqNum)
+ // Duplicate packet, just delete the payload.
+ if (data_buffer_[index].seqNum == packet.seqNum) {
+ delete[] packet.dataPtr;
return true;
+ }
// The packet buffer is full, try to expand the buffer.
while (ExpandBufferSize() && sequence_buffer_[seq_num % size_].used) {
@@ -87,8 +91,10 @@ bool PacketBuffer::InsertPacket(const VCMPacket& packet) {
index = seq_num % size_;
// Packet buffer is still full.
- if (sequence_buffer_[index].used)
+ if (sequence_buffer_[index].used) {
+ delete[] packet.dataPtr;
return false;
+ }
}
if (AheadOf(seq_num, last_seq_num_))
« no previous file with comments | « no previous file | webrtc/modules/video_coding/video_packet_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698