smacker demuxer: handle possible av_realloc() failure.
authorKostya Shishkov <kostya.shishkov@gmail.com>
Mon, 12 Sep 2011 07:40:42 +0000 (09:40 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 21 Sep 2011 17:34:25 +0000 (19:34 +0200)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavformat/smacker.c

index c22f6da..ad6f265 100644 (file)
@@ -286,15 +286,16 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
         for(i = 0; i < 7; i++) {
             if(flags & 1) {
                 int size;
+                uint8_t *tmpbuf;
+
                 size = avio_rl32(s->pb) - 4;
                 frame_size -= size;
                 frame_size -= 4;
                 smk->curstream++;
-                smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size);
-                if (!smk->bufs[smk->curstream]) {
-                    smk->buf_sizes[smk->curstream] = 0;
+                tmpbuf = av_realloc(smk->bufs[smk->curstream], size);
+                if (!tmpbuf)
                     return AVERROR(ENOMEM);
-                }
+                smk->bufs[smk->curstream] = tmpbuf;
                 smk->buf_sizes[smk->curstream] = size;
                 ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
                 if(ret != size)