Bug 1206211 - P2. Abort on OOM. r=kentuckyfriedtakahe, a=sylvestre
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 09 Dec 2015 09:55:16 +0100
changeset 260858 75343b2f90f41a0ab549d8a44b757b505b9674c3
parent 260857 f710e2e351b9de3913077ee4c1e722fc6c00ef97
child 260859 b9286af98c12fefe430abee3e819915f892c18c1
push id223
push usercbook@mozilla.com
push dateWed, 09 Dec 2015 08:55:35 +0000
treeherdermozilla-esr38@75343b2f90f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, sylvestre
bugs1206211
milestone38.4.0
Bug 1206211 - P2. Abort on OOM. r=kentuckyfriedtakahe, a=sylvestre
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -512,16 +512,19 @@ status_t MPEG4Extractor::readMetaData() 
     for (size_t i = 0; i < mPssh.size(); i++) {
         psshsize += 20 + mPssh[i].datalen;
     }
     if (psshsize > kMAX_ALLOCATION) {
         return ERROR_MALFORMED;
     }
     if (psshsize) {
         char *buf = (char*)malloc(psshsize);
+        if (!buf) {
+            return ERROR_MALFORMED;
+        }
         char *ptr = buf;
         for (size_t i = 0; i < mPssh.size(); i++) {
             memcpy(ptr, mPssh[i].uuid, 20); // uuid + length
             memcpy(ptr + 20, mPssh[i].data, mPssh[i].datalen);
             ptr += (20 + mPssh[i].datalen);
         }
         mFileMetaData->setData(kKeyPssh, 'pssh', buf, psshsize);
         free(buf);