Prevent crashes when copying a zero-size frame.
BUG=4451 R=magjed@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/44749004 Cr-Commit-Position: refs/heads/master@{#8802} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8802 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
6069032ebb
commit
6231fb6dac
@ -119,18 +119,17 @@ int I420VideoFrame::CreateFrame(const uint8_t* buffer_y,
|
||||
}
|
||||
|
||||
int I420VideoFrame::CopyFrame(const I420VideoFrame& videoFrame) {
|
||||
if (videoFrame.native_handle()) {
|
||||
if (videoFrame.IsZeroSize()) {
|
||||
video_frame_buffer_ = nullptr;
|
||||
} else if (videoFrame.native_handle()) {
|
||||
video_frame_buffer_ = videoFrame.video_frame_buffer();
|
||||
} else {
|
||||
int ret = CreateFrame(
|
||||
videoFrame.buffer(kYPlane),
|
||||
videoFrame.buffer(kUPlane),
|
||||
videoFrame.buffer(kVPlane),
|
||||
videoFrame.width(), videoFrame.height(), videoFrame.stride(kYPlane),
|
||||
CreateFrame(videoFrame.buffer(kYPlane), videoFrame.buffer(kUPlane),
|
||||
videoFrame.buffer(kVPlane), videoFrame.width(),
|
||||
videoFrame.height(), videoFrame.stride(kYPlane),
|
||||
videoFrame.stride(kUPlane), videoFrame.stride(kVPlane));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
timestamp_ = videoFrame.timestamp_;
|
||||
ntp_time_ms_ = videoFrame.ntp_time_ms_;
|
||||
render_time_ms_ = videoFrame.render_time_ms_;
|
||||
|
@ -46,6 +46,12 @@ TEST(TestI420VideoFrame, InitialValues) {
|
||||
EXPECT_EQ(kVideoRotation_0, frame.rotation());
|
||||
}
|
||||
|
||||
TEST(TestI420VideoFrame, CopiesInitialFrameWithoutCrashing) {
|
||||
I420VideoFrame frame;
|
||||
I420VideoFrame frame2;
|
||||
frame2.CopyFrame(frame);
|
||||
}
|
||||
|
||||
TEST(TestI420VideoFrame, WidthHeightValues) {
|
||||
I420VideoFrame frame;
|
||||
const int valid_value = 10;
|
||||
|
Loading…
x
Reference in New Issue
Block a user