Bug 1206211: P2. Abort on OOM. r=kentuckyfriedtakahe a=lizzard
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 03 Dec 2015 14:59:00 -0800
changeset 298573 c288fafdfb4fe809d3e57b964bfbcdd98ccd502c
parent 298572 3a00ac7ecacb81cf137b72b3c2c716033898e387
child 298574 107691986306d93dc7173a32429ea72fd459069e
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, lizzard
bugs1206211
milestone43.0
Bug 1206211: P2. Abort on OOM. r=kentuckyfriedtakahe a=lizzard
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
@@ -511,16 +511,19 @@ status_t MPEG4Extractor::readMetaData() 
     for (size_t i = 0; i < mPssh.Length(); 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.Length(); 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);