Fix potential use after move in RtpVideoStreamReceiver

When a frame is assembled `packet_infos` is moved and must be
re-initialized before potentially being used in another iteration of the
loop. Clear `packet_infos` immediately instead of relying on it being
implicitly cleared in the next iteration of the loop.

Bug: None
Change-Id: I954aaa0c6df296cc2a27b3ab496e49fac200f135
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238981
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Emil Lundmark <lndmrk@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35441}
This commit is contained in:
Emil Lundmark
2021-11-30 10:37:25 +01:00
committed by WebRTC LUCI CQ
parent d58ac5adf8
commit af5ca5af75
2 changed files with 4 additions and 4 deletions

View File

@ -780,8 +780,6 @@ void RtpVideoStreamReceiver::OnInsertedPacket(
max_nack_count = packet->times_nacked;
min_recv_time = packet_info.receive_time().ms();
max_recv_time = packet_info.receive_time().ms();
payloads.clear();
packet_infos.clear();
} else {
max_nack_count = std::max(max_nack_count, packet->times_nacked);
min_recv_time =
@ -824,6 +822,8 @@ void RtpVideoStreamReceiver::OnInsertedPacket(
last_packet.video_header.color_space, //
RtpPacketInfos(std::move(packet_infos)), //
std::move(bitstream)));
payloads.clear();
packet_infos.clear();
}
}
RTC_DCHECK(frame_boundary);

View File

@ -731,8 +731,6 @@ void RtpVideoStreamReceiver2::OnInsertedPacket(
max_nack_count = packet->times_nacked;
min_recv_time = packet_info.receive_time().ms();
max_recv_time = packet_info.receive_time().ms();
payloads.clear();
packet_infos.clear();
} else {
max_nack_count = std::max(max_nack_count, packet->times_nacked);
min_recv_time = std::min(min_recv_time, packet_info.receive_time().ms());
@ -772,6 +770,8 @@ void RtpVideoStreamReceiver2::OnInsertedPacket(
last_packet.video_header.color_space, //
RtpPacketInfos(std::move(packet_infos)), //
std::move(bitstream)));
payloads.clear();
packet_infos.clear();
}
}
RTC_DCHECK(frame_boundary);