diff options
author | Marco Nelissen <marcone@google.com> | 2015-08-23 19:27:02 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-23 19:27:02 +0000 |
commit | 719cd33e4ebc1c600772f81db28f81ccfe99ec4e (patch) | |
tree | 8903dc404465ebbf8f0d866f1979024938f08572 /media/libstagefright/MPEG4Extractor.cpp | |
parent | 4bb4736eb6b5038385c2c0e8c28e4d2df9add929 (diff) | |
parent | 492bba08202a601e96a13b26422c85b3fb1a5ee0 (diff) | |
download | frameworks_av-719cd33e4ebc1c600772f81db28f81ccfe99ec4e.zip frameworks_av-719cd33e4ebc1c600772f81db28f81ccfe99ec4e.tar.gz frameworks_av-719cd33e4ebc1c600772f81db28f81ccfe99ec4e.tar.bz2 |
am 492bba08: am d18bb120: am 09f71c56: am dedaca6f: Limit allocations to avoid out-of-memory
* commit '492bba08202a601e96a13b26422c85b3fb1a5ee0':
Limit allocations to avoid out-of-memory
Diffstat (limited to 'media/libstagefright/MPEG4Extractor.cpp')
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index e009a0e..66a3793 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -3089,16 +3089,24 @@ status_t MPEG4Source::start(MetaData *params) { mWantsNALFragments = false; } + int32_t tmp; + CHECK(mFormat->findInt32(kKeyMaxInputSize, &tmp)); + size_t max_size = tmp; + + // A somewhat arbitrary limit that should be sufficient for 8k video frames + // If you see the message below for a valid input stream: increase the limit + if (max_size > 64 * 1024 * 1024) { + ALOGE("bogus max input size: %zu", max_size); + return ERROR_MALFORMED; + } mGroup = new MediaBufferGroup; - - int32_t max_size; - CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size)); - mGroup->add_buffer(new MediaBuffer(max_size)); mSrcBuffer = new (std::nothrow) uint8_t[max_size]; if (mSrcBuffer == NULL) { // file probably specified a bad max size + delete mGroup; + mGroup = NULL; return ERROR_MALFORMED; } |