[FFmpeg-cvslog] mpegtsenc: zero pointers after freeing

Michael Niedermayer git at videolan.org
Sun Jun 3 03:49:20 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jun  3 03:44:16 2012 +0200| [c983ca5b90b80feb65a82678253340992cb54040] | committer: Michael Niedermayer

mpegtsenc: zero pointers after freeing

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c983ca5b90b80feb65a82678253340992cb54040
---

 libavformat/mpegtsenc.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 9e066de..1df8044 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -723,9 +723,10 @@ static int mpegts_write_header(AVFormatContext *s)
         if (ts_st) {
             av_freep(&ts_st->payload);
             if (ts_st->amux) {
-                av_free(ts_st->amux->pb->buffer);
-                av_free(ts_st->amux->pb);
+                av_freep(&ts_st->amux->pb->buffer);
+                av_freep(&ts_st->amux->pb);
                 avformat_free_context(ts_st->amux);
+                ts_st->amux = NULL;
             }
         }
         av_freep(&st->priv_data);
@@ -1235,9 +1236,10 @@ static int mpegts_write_end(AVFormatContext *s)
         MpegTSWriteStream *ts_st = st->priv_data;
         av_freep(&ts_st->payload);
         if (ts_st->amux) {
-            av_free(ts_st->amux->pb->buffer);
-            av_free(ts_st->amux->pb);
+            av_freep(&ts_st->amux->pb->buffer);
+            av_freep(&ts_st->amux->pb);
             avformat_free_context(ts_st->amux);
+            ts_st->amux = NULL;
         }
     }
 



More information about the ffmpeg-cvslog mailing list