[FFmpeg-devel] [RFC] missing av_free_packet on error?

Reimar Döffinger Reimar.Doeffinger
Thu Jul 10 21:53:15 CEST 2008

I have been trying to fix
and thus noticed the following code in libavformat/eacdata.c:
if (av_get_packet(s->pb, pkt, packet_size) != packet_size)
   return AVERROR(EIO);

Whereas av_find_stream_info() assumes that if there is an error, there
is no packet to free.
My question is: where is the error, where should it be fixed?
In the demuxer, in av_find_stream_info, av_read_... or maybe this check
should be moved to av_get_packet, to make it always fail when not all
requested data could be read?
IMO in the demuxer, in which case I suggest this change:

--- libavformat/eacdata.c       (revision 14158)
+++ libavformat/eacdata.c       (working copy)
@@ -83,8 +83,10 @@
     CdataDemuxContext *cdata = s->priv_data;
     int packet_size = 76*cdata->channels;
-    if (av_get_packet(s->pb, pkt, packet_size) != packet_size)
+    if (av_get_packet(s->pb, pkt, packet_size) != packet_size) {
+        av_free_packet(pkt);
         return AVERROR(EIO);
+    }
     pkt->pts = cdata->audio_pts++;
     return 1;

Reimar D?ffinger

More information about the ffmpeg-devel mailing list