[FFmpeg-cvslog] avformat/mov: Do not allocate empty extradata

Michael Niedermayer git at videolan.org
Fri Jul 22 00:18:16 EEST 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Thu Jul 21 21:43:59 2016 +0200| [38cc5c298c988950d2bfa0d16408f07ee7be7f3c] | committer: Michael Niedermayer

avformat/mov: Do not allocate empty extradata

Fixes Ticket5723

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/mov.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3843ceb..7c8f784 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2345,12 +2345,14 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         return ret;
 
     /* Restore back the primary extradata. */
-    av_free(st->codecpar->extradata);
+    av_freep(&st->codecpar->extradata);
     st->codecpar->extradata_size = sc->extradata_size[0];
-    st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!st->codecpar->extradata)
-        return AVERROR(ENOMEM);
-    memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);
+    if (sc->extradata_size[0]) {
+        st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE);
+        if (!st->codecpar->extradata)
+            return AVERROR(ENOMEM);
+        memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);
+    }
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list