summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-08-23 19:08:25 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-23 19:08:25 +0000
commit09f71c5621799e0f030b4a8058d2fb4df5977de0 (patch)
treee3f6d8a851739e695ddc2795dd9cd2366eef45c7
parenteecc406f462ef2b3a73cd6bf3c05f7cb45382276 (diff)
parentdedaca6f04ac9f95fabe3b64d44cd1a2050f079e (diff)
downloadframeworks_av-09f71c5621799e0f030b4a8058d2fb4df5977de0.zip
frameworks_av-09f71c5621799e0f030b4a8058d2fb4df5977de0.tar.gz
frameworks_av-09f71c5621799e0f030b4a8058d2fb4df5977de0.tar.bz2
am dedaca6f: Limit allocations to avoid out-of-memory
* commit 'dedaca6f04ac9f95fabe3b64d44cd1a2050f079e': Limit allocations to avoid out-of-memory
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 9366a51..e9ecc45 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -2700,16 +2700,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;
}