]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/bethsoftvid.c
rtpenc_mpegts: Free the right ->pb in the error path in the init function
[ffmpeg] / libavformat / bethsoftvid.c
index 120e145a76e5f4f6fe6866bad431a30eee8e8c1b..135a3c491ae6cc855c3a7142417298d307b70a94 100644 (file)
@@ -177,7 +177,6 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
     if ((ret = av_new_packet(pkt, vidbuf_nbytes)) < 0)
         goto fail;
     memcpy(pkt->data, vidbuf_start, vidbuf_nbytes);
-    av_free(vidbuf_start);
 
     pkt->pos = position;
     pkt->stream_index = vid->video_index;
@@ -189,12 +188,15 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
     if (vid->palette) {
         uint8_t *pdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
                                                  BVID_PALETTE_SIZE);
+        if (!pdata) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
         memcpy(pdata, vid->palette, BVID_PALETTE_SIZE);
         av_freep(&vid->palette);
     }
 
     vid->nframes--;  // used to check if all the frames were read
-    return 0;
 fail:
     av_free(vidbuf_start);
     return ret;