[FFmpeg-cvslog] avformat/wtvdec: Use av_freep() avoid leaving stale pointers in memory

Michael Niedermayer git at videolan.org
Thu Dec 25 13:04:40 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Dec 25 12:41:36 2014 +0100| [443bd2715d42c8cd867a1f47ff6edf44e12d53db] | committer: Michael Niedermayer

avformat/wtvdec: Use av_freep() avoid leaving stale pointers in memory

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

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

 libavformat/wtvdec.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 7fc5e63..f200300 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -204,8 +204,8 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
     wf->sector_bits = length & (1ULL<<63) ? WTV_SECTOR_BITS : WTV_BIGSECTOR_BITS;
 
     if (!wf->nb_sectors) {
-        av_free(wf->sectors);
-        av_free(wf);
+        av_freep(&wf->sectors);
+        av_freep(&wf);
         return NULL;
     }
 
@@ -224,25 +224,25 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
     /* seek to initial sector */
     wf->position = 0;
     if (seek_by_sector(s->pb, wf->sectors[0], 0) < 0) {
-        av_free(wf->sectors);
-        av_free(wf);
+        av_freep(&wf->sectors);
+        av_freep(&wf);
         return NULL;
     }
 
     wf->pb_filesystem = s->pb;
     buffer = av_malloc(1 << wf->sector_bits);
     if (!buffer) {
-        av_free(wf->sectors);
-        av_free(wf);
+        av_freep(&wf->sectors);
+        av_freep(&wf);
         return NULL;
     }
 
     pb = avio_alloc_context(buffer, 1 << wf->sector_bits, 0, wf,
                            wtvfile_read_packet, NULL, wtvfile_seek);
     if (!pb) {
-        av_free(buffer);
-        av_free(wf->sectors);
-        av_free(wf);
+        av_freep(&buffer);
+        av_freep(&wf->sectors);
+        av_freep(&wf);
     }
     return pb;
 }
@@ -304,7 +304,7 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
 static void wtvfile_close(AVIOContext *pb)
 {
     WtvFile *wf = pb->opaque;
-    av_free(wf->sectors);
+    av_freep(&wf->sectors);
     av_freep(&pb->opaque);
     av_freep(&pb->buffer);
     av_free(pb);



More information about the ffmpeg-cvslog mailing list