Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78df80c2 authored by Wei Jia's avatar Wei Jia Committed by Android Git Automerger
Browse files

am 65842db0: Merge commit \'b46eb8d9\' into HEAD

* commit '65842db0':
  SoftAVCEnc: check requested memory size before allocation.
parents 6faf4618 65842db0
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -234,6 +234,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() {
            || mStoreMetaDataInBuffers) {
            || mStoreMetaDataInBuffers) {
        // Color conversion is needed.
        // Color conversion is needed.
        free(mInputFrameData);
        free(mInputFrameData);
        if (((uint64_t)mVideoWidth * mVideoHeight) > ((uint64_t)INT32_MAX / 3)) {
            ALOGE("Buffer size is too big.");
            return OMX_ErrorUndefined;
        }
        mInputFrameData =
        mInputFrameData =
            (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1);
            (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1);
        CHECK(mInputFrameData != NULL);
        CHECK(mInputFrameData != NULL);
@@ -255,6 +259,10 @@ OMX_ERRORTYPE SoftAVCEncoder::initEncParams() {
    int32_t nMacroBlocks = ((((mVideoWidth + 15) >> 4) << 4) *
    int32_t nMacroBlocks = ((((mVideoWidth + 15) >> 4) << 4) *
            (((mVideoHeight + 15) >> 4) << 4)) >> 8;
            (((mVideoHeight + 15) >> 4) << 4)) >> 8;
    CHECK(mSliceGroup == NULL);
    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);
    mSliceGroup = (uint32_t *) malloc(sizeof(uint32_t) * nMacroBlocks);
    CHECK(mSliceGroup != NULL);
    CHECK(mSliceGroup != NULL);
    for (int ii = 0, idx = 0; ii < nMacroBlocks; ++ii) {
    for (int ii = 0, idx = 0; ii < nMacroBlocks; ++ii) {