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

Commit ae7fae18 authored by Ray Essick's avatar Ray Essick Committed by android-build-merger
Browse files

Merge "Fix TOCTOU problem in libstagefright_soft_aacenc" into klp-dev am:...

Merge "Fix TOCTOU problem in libstagefright_soft_aacenc" into klp-dev am: 2076915c am: dcda2ec2 am: f5c7784d am: c3de266a am: 8655d4fc am: b05be00f am: eb58ce5b am: a8305391
am: e973c655

Change-Id: Icb9263d13832bc7826aa67af92f61bafbff4b7a1
parents 3a3cc883 e973c655
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0
#define LOG_TAG "SoftAACEncoder2"
#define LOG_TAG "SoftAACEncoder2"
#include <log/log.h>
#include <utils/Log.h>
#include <utils/Log.h>


#include "SoftAACEncoder2.h"
#include "SoftAACEncoder2.h"
@@ -51,6 +52,7 @@ SoftAACEncoder2::SoftAACEncoder2(
      mSentCodecSpecificData(false),
      mSentCodecSpecificData(false),
      mInputSize(0),
      mInputSize(0),
      mInputFrame(NULL),
      mInputFrame(NULL),
      mAllocatedFrameSize(0),
      mInputTimeUs(-1ll),
      mInputTimeUs(-1ll),
      mSawInputEOS(false),
      mSawInputEOS(false),
      mSignalledError(false) {
      mSignalledError(false) {
@@ -523,6 +525,15 @@ void SoftAACEncoder2::onQueueFilled(OMX_U32 /* portIndex */) {


            if (mInputFrame == NULL) {
            if (mInputFrame == NULL) {
                mInputFrame = new int16_t[numBytesPerInputFrame / sizeof(int16_t)];
                mInputFrame = new int16_t[numBytesPerInputFrame / sizeof(int16_t)];
                mAllocatedFrameSize = numBytesPerInputFrame;
            } else if (mAllocatedFrameSize != numBytesPerInputFrame) {
                ALOGE("b/34621073: changed size from %d to %d",
                        (int)mAllocatedFrameSize, (int)numBytesPerInputFrame);
                android_errorWriteLog(0x534e4554,"34621073");
                delete mInputFrame;
                mInputFrame = new int16_t[numBytesPerInputFrame / sizeof(int16_t)];
                mAllocatedFrameSize = numBytesPerInputFrame;

            }
            }


            if (mInputSize == 0) {
            if (mInputSize == 0) {
@@ -673,6 +684,7 @@ void SoftAACEncoder2::onReset() {
    delete[] mInputFrame;
    delete[] mInputFrame;
    mInputFrame = NULL;
    mInputFrame = NULL;
    mInputSize = 0;
    mInputSize = 0;
    mAllocatedFrameSize = 0;


    mSentCodecSpecificData = false;
    mSentCodecSpecificData = false;
    mInputTimeUs = -1ll;
    mInputTimeUs = -1ll;
+1 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ private:
    bool mSentCodecSpecificData;
    bool mSentCodecSpecificData;
    size_t mInputSize;
    size_t mInputSize;
    int16_t *mInputFrame;
    int16_t *mInputFrame;
    size_t mAllocatedFrameSize;
    int64_t mInputTimeUs;
    int64_t mInputTimeUs;


    bool mSawInputEOS;
    bool mSawInputEOS;