Browse code

rmdec: Check memory allocations from ff_rm_alloc_rmstream()

Bug-Id: CID 1257835

Hugo Beauzée-Luyssen authored on 2015/02/02 03:19:46
Showing 2 changed files
... ...
@@ -434,6 +434,8 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index,
434 434
                     rdt->nb_rmst = count;
435 435
                 }
436 436
                 rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream();
437
+                if (!rdt->rmst[s->streams[n]->index])
438
+                    return AVERROR(ENOMEM);
437 439
                 rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2);
438 440
            }
439 441
     }
... ...
@@ -109,6 +109,8 @@ static void rm_read_metadata(AVFormatContext *s, AVIOContext *pb, int wide)
109 109
 RMStream *ff_rm_alloc_rmstream (void)
110 110
 {
111 111
     RMStream *rms = av_mallocz(sizeof(RMStream));
112
+    if (!rms)
113
+        return NULL;
112 114
     rms->curpic_num = -1;
113 115
     return rms;
114 116
 }
... ...
@@ -416,6 +418,8 @@ static int rm_read_header_old(AVFormatContext *s)
416 416
     if (!st)
417 417
         return -1;
418 418
     st->priv_data = ff_rm_alloc_rmstream();
419
+    if (!st->priv_data)
420
+        return AVERROR(ENOMEM);
419 421
     return rm_read_audio_stream_info(s, s->pb, st, st->priv_data, 1);
420 422
 }
421 423
 
... ...
@@ -493,6 +497,8 @@ static int rm_read_header(AVFormatContext *s)
493 493
             get_str8(pb, buf, sizeof(buf)); /* mimetype */
494 494
             st->codec->codec_type = AVMEDIA_TYPE_DATA;
495 495
             st->priv_data = ff_rm_alloc_rmstream();
496
+            if (!st->priv_data)
497
+                return AVERROR(ENOMEM);
496 498
             if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
497 499
                                           avio_rb32(pb)) < 0)
498 500
                 return -1;