[FFmpeg-devel] [PATCH 2/2] Free allocated packet before returning from av_read_frame_internal.

Reimar Döffinger Reimar.Doeffinger
Wed Jul 14 23:15:04 CEST 2010


On Thu, Jul 15, 2010 at 02:35:45AM +0530, Jai Menon wrote:
> ---
>  libavformat/utils.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 6fa4dff..bbe6a64 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1118,6 +1118,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
>                              goto got_packet;
>                      }
>                  }
> +                av_free_packet(&cur_pkt);

It is missing from the av_read_frame documentation, but from the read_packet for
the formats:
               When returning an error, pkt must not have been allocated
               or must be freed before returning

You really shouldn't touch cur_pkt when the function failed, it might not even have been
fully/properly initialized.



More information about the ffmpeg-devel mailing list