]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/brstm.c
avformat/avidec: Fix memleak when allocating DVDemuxContext fails
[ffmpeg] / libavformat / brstm.c
index 87690e3f73e421ebf870edc15ae9417bf92ff4c5..ca965ed7e1999f8e76d73a75e0e45bfddeea7aed 100644 (file)
@@ -38,7 +38,7 @@ typedef struct BRSTMDemuxContext {
     int         little_endian;
 } BRSTMDemuxContext;
 
-static int probe(AVProbeData *p)
+static int probe(const AVProbeData *p)
 {
     if (AV_RL32(p->buf) == MKTAG('R','S','T','M') &&
         (AV_RL16(p->buf + 4) == 0xFFFE ||
@@ -47,7 +47,7 @@ static int probe(AVProbeData *p)
     return 0;
 }
 
-static int probe_bfstm(AVProbeData *p)
+static int probe_bfstm(const AVProbeData *p)
 {
     if ((AV_RL32(p->buf) == MKTAG('F','S','T','M') ||
          AV_RL32(p->buf) == MKTAG('C','S','T','M')) &&
@@ -403,8 +403,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
             (32 + 4 + size) > (INT_MAX / par->channels) ||
             (32 + 4 + size) * par->channels > INT_MAX - 8)
             return AVERROR_INVALIDDATA;
-        if (av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels) < 0)
-            return AVERROR(ENOMEM);
+        if ((ret = av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels)) < 0)
+            return ret;
         dst = pkt->data;
         if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
             bytestream_put_le32(&dst, size * par->channels);
@@ -422,8 +422,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
             dst += size;
             avio_skip(s->pb, skip);
             if (ret != size) {
-                av_packet_unref(pkt);
-                break;
+                return AVERROR(EIO);
             }
         }
         pkt->duration = samples;