diff options
author | Wei Jia <wjia@google.com> | 2015-08-14 17:16:46 -0700 |
---|---|---|
committer | Wei Jia <wjia@google.com> | 2015-08-14 17:16:46 -0700 |
commit | 479b4de0d267eb7d4c419f4da0069186a952ad17 (patch) | |
tree | 07f2745284a903befd67cfa22a7d46731c623975 /media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp | |
parent | 3ce293842fed1b3abd2ff0aecd2a0c70a55086ee (diff) | |
download | frameworks_av-479b4de0d267eb7d4c419f4da0069186a952ad17.zip frameworks_av-479b4de0d267eb7d4c419f4da0069186a952ad17.tar.gz frameworks_av-479b4de0d267eb7d4c419f4da0069186a952ad17.tar.bz2 |
SoftAVCEnc: check requested memory size before allocation.
Bug: 20674674
Change-Id: I569e7a9b33fe64779a40e55539929c3dc4303c19
(cherry picked from commit f6fe4340219a8e674f3250fe32d4697ec8184b24)
Diffstat (limited to 'media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp')
-rw-r--r-- | media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp index 1d66120..be65c94 100644 --- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp +++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp @@ -257,6 +257,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() { if (mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { // Color conversion is needed. CHECK(mInputFrameData == NULL); + if (((uint64_t)mVideoWidth * mVideoHeight) > ((uint64_t)INT32_MAX / 3)) { + ALOGE("Buffer size is too big."); + return OMX_ErrorUndefined; + } mInputFrameData = (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1); CHECK(mInputFrameData != NULL); @@ -278,6 +282,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() { int32_t nMacroBlocks = ((((mVideoWidth + 15) >> 4) << 4) * (((mVideoHeight + 15) >> 4) << 4)) >> 8; CHECK(mSliceGroup == NULL); + if (nMacroBlocks > SIZE_MAX / sizeof(uint32_t)) { + ALOGE("requested memory size is too big."); + return OMX_ErrorUndefined; + } mSliceGroup = (uint32_t *) malloc(sizeof(uint32_t) * nMacroBlocks); CHECK(mSliceGroup != NULL); for (int ii = 0, idx = 0; ii < nMacroBlocks; ++ii) { @@ -698,6 +706,10 @@ OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter( if (mStoreMetaDataInBuffers) { mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar; if (mInputFrameData == NULL) { + if (((uint64_t)mVideoWidth * mVideoHeight) > ((uint64_t)INT32_MAX / 3)) { + ALOGE("Buffer size is too big."); + return OMX_ErrorUndefined; + } mInputFrameData = (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1); } |