summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2015-08-18 01:31:43 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-18 01:31:43 +0000
commit78df80c26352bdbe3dc3725a6d937f60fc340127 (patch)
treef2341971131c08ee8463ab0b6278d938786aedec
parent6faf46183099d4ed1a59daf6ae1490d3d891ada4 (diff)
parent65842db06c2d77e53cc5ac61692160d844cc7d0a (diff)
downloadframeworks_av-78df80c26352bdbe3dc3725a6d937f60fc340127.zip
frameworks_av-78df80c26352bdbe3dc3725a6d937f60fc340127.tar.gz
frameworks_av-78df80c26352bdbe3dc3725a6d937f60fc340127.tar.bz2
am 65842db0: Merge commit \'b46eb8d9\' into HEAD
* commit '65842db06c2d77e53cc5ac61692160d844cc7d0a': SoftAVCEnc: check requested memory size before allocation.
-rw-r--r--media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp8
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 ed3dca0..523e785 100644
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
+++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
@@ -234,6 +234,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() {
|| mStoreMetaDataInBuffers) {
// 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((mVideoWidth * mVideoHeight * 3 ) >> 1);
CHECK(mInputFrameData != NULL);
@@ -255,6 +259,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) {