diff mbox

[FFmpeg-devel] avformat/utils: fix memory leak in avformat_free_context

Message ID 20170731180820.13180-1-ssiloti@bittorrent.com
State New
Headers show

Commit Message

Steven Siloti July 31, 2017, 6:08 p.m. UTC
The pointer to the packet queue is stored in the internal structure
so the queue needs to be flushed before internal is freed.

Signed-off-by: Steven Siloti <ssiloti@bittorrent.com>
---
 libavformat/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Siloti Aug. 3, 2017, 4:29 p.m. UTC | #1
On Mon, Jul 31, 2017 at 11:08 AM, Steven Siloti <ssiloti@bittorrent.com>
wrote:

> The pointer to the packet queue is stored in the internal structure
> so the queue needs to be flushed before internal is freed.
>
> Signed-off-by: Steven Siloti <ssiloti@bittorrent.com>
> ---
>  libavformat/utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 38d247c6cd..58283616dc 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4333,8 +4333,8 @@ void avformat_free_context(AVFormatContext *s)
>      av_dict_free(&s->metadata);
>      av_dict_free(&s->internal->id3v2_meta);
>      av_freep(&s->streams);
> -    av_freep(&s->internal);
>      flush_packet_queue(s);
> +    av_freep(&s->internal);
>      av_free(s);
>  }
>
> --
> 2.13.0.windows.1
>
> Is there something wrong with this patch? It seems like a straightforward
fix to me. Perhaps you would prefer it as an attachment. If so, attached.
Michael Niedermayer Aug. 5, 2017, 9:08 p.m. UTC | #2
On Thu, Aug 03, 2017 at 09:29:37AM -0700, Steven Siloti wrote:
> On Mon, Jul 31, 2017 at 11:08 AM, Steven Siloti <ssiloti@bittorrent.com>
> wrote:
> 
> > The pointer to the packet queue is stored in the internal structure
> > so the queue needs to be flushed before internal is freed.
> >
> > Signed-off-by: Steven Siloti <ssiloti@bittorrent.com>
> > ---
> >  libavformat/utils.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index 38d247c6cd..58283616dc 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -4333,8 +4333,8 @@ void avformat_free_context(AVFormatContext *s)
> >      av_dict_free(&s->metadata);
> >      av_dict_free(&s->internal->id3v2_meta);
> >      av_freep(&s->streams);
> > -    av_freep(&s->internal);
> >      flush_packet_queue(s);
> > +    av_freep(&s->internal);
> >      av_free(s);
> >  }
> >
> > --
> > 2.13.0.windows.1
> >
> > Is there something wrong with this patch? It seems like a straightforward
> fix to me. Perhaps you would prefer it as an attachment. If so, attached.

>  utils.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> dcd295b47267244aa767fa9cace848bde36e1043  0001-avformat-utils-fix-memory-leak-in-avformat_free_cont.patch
> From 5ec9a446fdc5874d859f3a9d92a0b5d9f82583aa Mon Sep 17 00:00:00 2001
> From: Steven Siloti <ssiloti@bittorrent.com>
> Date: Tue, 18 Jul 2017 11:26:39 -0700
> Subject: [PATCH] avformat/utils: fix memory leak in avformat_free_context
> 
> The pointer to the packet queue is stored in the internal structure
> so the queue needs to be flushed before internal is freed.
> 
> Signed-off-by: Steven Siloti <ssiloti@bittorrent.com>
> ---
>  libavformat/utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied

thx

[...]
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 38d247c6cd..58283616dc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4333,8 +4333,8 @@  void avformat_free_context(AVFormatContext *s)
     av_dict_free(&s->metadata);
     av_dict_free(&s->internal->id3v2_meta);
     av_freep(&s->streams);
-    av_freep(&s->internal);
     flush_packet_queue(s);
+    av_freep(&s->internal);
     av_free(s);
 }