diff options
author | Wei Jia <wjia@google.com> | 2015-08-18 01:39:39 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-18 01:39:39 +0000 |
commit | ab33de61ccf1d0fab39573a79cf8372045bbda1a (patch) | |
tree | ffa0f8acea31da78f2c73f61bb64e0dc80f08d48 | |
parent | 2c0adb690ad2057d753a1d6892e9534e1648651b (diff) | |
parent | 78df80c26352bdbe3dc3725a6d937f60fc340127 (diff) | |
download | frameworks_av-ab33de61ccf1d0fab39573a79cf8372045bbda1a.zip frameworks_av-ab33de61ccf1d0fab39573a79cf8372045bbda1a.tar.gz frameworks_av-ab33de61ccf1d0fab39573a79cf8372045bbda1a.tar.bz2 |
am 78df80c2: am 65842db0: Merge commit \'b46eb8d9\' into HEAD
* commit '78df80c26352bdbe3dc3725a6d937f60fc340127':
SoftAVCEnc: check requested memory size before allocation.
-rw-r--r-- | media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp index 24dfc29..7add08f 100644 --- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp +++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp @@ -244,6 +244,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() { if (mColorFormat != OMX_COLOR_FormatYUV420Planar || mInputDataIsMeta) { // Color conversion is needed. free(mInputFrameData); + if (((uint64_t)mVideoWidth * mVideoHeight) > ((uint64_t)INT32_MAX / 3)) { + ALOGE("Buffer size is too big."); + return OMX_ErrorUndefined; + } mInputFrameData = (uint8_t *) malloc((mWidth * mHeight * 3 ) >> 1); CHECK(mInputFrameData != NULL); @@ -264,6 +268,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() { int32_t nMacroBlocks = divUp(mWidth, 16) * divUp(mHeight, 16); 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) { |