mpegtsenc: Clear st->priv_data when freeing it

Message ID 1304952122-57025-1-git-send-email-martin@martin.st
State Committed
Commit ed87375dd555a1e7798dcd56c967af0171525a26
Headers show

Commit Message

Martin Storsjö May 9, 2011, 2:42 p.m.
If not cleared, the caller might try to free it.
---
 libavformat/mpegtsenc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Mans Rullgard May 9, 2011, 2:47 p.m. | #1
Martin Storsjö <martin@martin.st> writes:

> If not cleared, the caller might try to free it.
> ---
>  libavformat/mpegtsenc.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index bf66aa0..55a16f7 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -588,7 +588,7 @@ static int mpegts_write_header(AVFormatContext *s)
>      av_free(pids);
>      for(i = 0;i < s->nb_streams; i++) {
>          st = s->streams[i];
> -        av_free(st->priv_data);
> +        av_freep(&st->priv_data);
>      }
>      return -1;
>  }
> -- 

Looks OK.

Patch

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index bf66aa0..55a16f7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -588,7 +588,7 @@  static int mpegts_write_header(AVFormatContext *s)
     av_free(pids);
     for(i = 0;i < s->nb_streams; i++) {
         st = s->streams[i];
-        av_free(st->priv_data);
+        av_freep(&st->priv_data);
     }
     return -1;
 }