Reallocate encoded buffer size if needed. Initially set to the input image size.

Issue may occur for very small input images (e.g. 4x4) when encoded image length > input image size.

BUG=chromium:578193

Review URL: https://codereview.webrtc.org/1603643006

Cr-Commit-Position: refs/heads/master@{#11329}
This commit is contained in:
asapersson
2016-01-21 01:11:35 -08:00
committed by Commit bot
parent d26fadb454
commit d9f641e341
2 changed files with 33 additions and 0 deletions

View File

@ -659,6 +659,12 @@ int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
int part_idx = 0;
CodecSpecificInfo codec_specific;
if (pkt->data.frame.sz > encoded_image_._size) {
delete[] encoded_image_._buffer;
encoded_image_._size = pkt->data.frame.sz;
encoded_image_._buffer = new uint8_t[encoded_image_._size];
}
assert(pkt->kind == VPX_CODEC_CX_FRAME_PKT);
memcpy(&encoded_image_._buffer[encoded_image_._length], pkt->data.frame.buf,
pkt->data.frame.sz);