summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-08-20 19:41:14 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-20 19:41:14 +0000
commit6020f06633f8cac09f47e561cc389c5b9b152464 (patch)
treed40a01deb5043dbf7c1f01c29165f74719b1b717
parent2fe61ed032e083dc39265f3b88274fcb8fbeed9b (diff)
parentb294a97a6fed15d379ce11084166780e7d9dd883 (diff)
downloadframeworks_av-6020f06633f8cac09f47e561cc389c5b9b152464.zip
frameworks_av-6020f06633f8cac09f47e561cc389c5b9b152464.tar.gz
frameworks_av-6020f06633f8cac09f47e561cc389c5b9b152464.tar.bz2
am b294a97a: am 6cba5819: am 51bfaf6c: am 1afea551: am ce73af07: DO NOT MERGE Fail more gracefully on allocation failure
* commit 'b294a97a6fed15d379ce11084166780e7d9dd883': DO NOT MERGE Fail more gracefully on allocation failure
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 09a963d..0ddba7b 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -287,7 +287,7 @@ MPEG4Extractor::~MPEG4Extractor() {
SINF *sinf = mFirstSINF;
while (sinf) {
SINF *next = sinf->next;
- delete sinf->IPMPData;
+ delete[] sinf->IPMPData;
delete sinf;
sinf = next;
}
@@ -540,7 +540,11 @@ status_t MPEG4Extractor::parseDrmSINF(off64_t *offset, off64_t data_offset) {
return ERROR_MALFORMED;
}
sinf->len = dataLen - 3;
- sinf->IPMPData = new char[sinf->len];
+ sinf->IPMPData = new (std::nothrow) char[sinf->len];
+ if (sinf->IPMPData == NULL) {
+ return ERROR_MALFORMED;
+ }
+ data_offset += 2;
if (mDataSource->readAt(data_offset + 2, sinf->IPMPData, sinf->len) < sinf->len) {
return ERROR_IO;
@@ -1401,8 +1405,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
if ((chunk_size > SIZE_MAX) || (SIZE_MAX - chunk_size <= size)) {
return ERROR_MALFORMED;
}
-
- uint8_t *buffer = new uint8_t[size + chunk_size];
+ uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size];
if (buffer == NULL) {
return ERROR_MALFORMED;
}
@@ -1571,7 +1574,10 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) {
return ERROR_MALFORMED;
}
- uint8_t *buffer = new uint8_t[size + 1];
+ uint8_t *buffer = new (std::nothrow) uint8_t[size + 1];
+ if (buffer == NULL) {
+ return ERROR_MALFORMED;
+ }
if (mDataSource->readAt(
offset, buffer, size) != (ssize_t)size) {
delete[] buffer;
@@ -1976,7 +1982,11 @@ status_t MPEG4Source::start(MetaData *params) {
mGroup->add_buffer(new MediaBuffer(max_size));
- mSrcBuffer = new uint8_t[max_size];
+ mSrcBuffer = new (std::nothrow) uint8_t[max_size];
+ if (mSrcBuffer == NULL) {
+ // file probably specified a bad max size
+ return ERROR_MALFORMED;
+ }
mStarted = true;