i420:verify image length

BUG=

Review URL: https://webrtc-codereview.appspot.com/930016

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3071 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-11-09 18:48:30 +00:00
parent 701567a864
commit f875fd22c0

View File

@ -171,10 +171,18 @@ I420Decoder::Decode(const EncodedImage& inputImage,
if (inputImage._length <= 0) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (inputImage._completeFrame == false) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
if (!_inited) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
// Verify that the available length is sufficient:
int req_length = CalcBufferSize(kI420, _width, _height);
if (req_length > static_cast<int>(inputImage._length)) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
// Set decoded image parameters.
int half_width = (_width + 1) / 2;
int half_height = (_height + 1) / 2;