segafilm: Check for memory allocation failures in segafilm demuxer.
authorLaurent Aimar <fenrir@videolan.org>
Mon, 12 Sep 2011 18:58:35 +0000 (20:58 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 21 Sep 2011 17:36:58 +0000 (19:36 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 7cbe02575868e7d25acf3d319ece664702700f0a)

libavformat/segafilm.c

index ae194d4..e712ebf 100644 (file)
@@ -167,6 +167,8 @@ static int film_read_header(AVFormatContext *s,
     if(film->sample_count >= UINT_MAX / sizeof(film_sample))
         return -1;
     film->sample_table = av_malloc(film->sample_count * sizeof(film_sample));
+    if (!film->sample_table)
+        return AVERROR(ENOMEM);
 
     for(i=0; i<s->nb_streams; i++)
         av_set_pts_info(s->streams[i], 33, 1, film->base_clock);
@@ -238,6 +240,10 @@ static int film_read_packet(AVFormatContext *s,
             av_free(film->stereo_buffer);
             film->stereo_buffer_size = sample->sample_size;
             film->stereo_buffer = av_malloc(film->stereo_buffer_size);
+            if (!film->stereo_buffer) {
+                film->stereo_buffer_size = 0;
+                return AVERROR(ENOMEM);
+            }
         }
 
         pkt->pos= avio_tell(pb);