[FFmpeg-cvslog] avformat/iff: Use ff_alloc_extradata

Andreas Rheinhardt git at videolan.org
Wed Dec 11 17:55:19 EET 2019


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Tue Dec 10 02:41:45 2019 +0100| [86e9747c634bc17ef8335d12191aa9e7a897fd64] | committer: Michael Niedermayer

avformat/iff: Use ff_alloc_extradata

Besides improved readability it also zeroes the padding which has been
forgotten here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/iff.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavformat/iff.c b/libavformat/iff.c
index 2a3729f97e..9cee31a86b 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -525,10 +525,10 @@ static int iff_read_header(AVFormatContext *s)
                         data_size);
                  return AVERROR_INVALIDDATA;
             }
-            st->codecpar->extradata_size = data_size + IFF_EXTRA_VIDEO_SIZE;
-            st->codecpar->extradata      = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (!st->codecpar->extradata)
-                return AVERROR(ENOMEM);
+            res = ff_alloc_extradata(st->codecpar,
+                                     data_size + IFF_EXTRA_VIDEO_SIZE);
+            if (res < 0)
+                return res;
             if (avio_read(pb, st->codecpar->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0) {
                 av_freep(&st->codecpar->extradata);
                 st->codecpar->extradata_size = 0;
@@ -771,10 +771,9 @@ static int iff_read_header(AVFormatContext *s)
         iff->transparency = transparency;
 
         if (!st->codecpar->extradata) {
-            st->codecpar->extradata_size = IFF_EXTRA_VIDEO_SIZE;
-            st->codecpar->extradata      = av_malloc(IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (!st->codecpar->extradata)
-                return AVERROR(ENOMEM);
+            int ret = ff_alloc_extradata(st->codecpar, IFF_EXTRA_VIDEO_SIZE);
+            if (ret < 0)
+                return ret;
         }
         av_assert0(st->codecpar->extradata_size >= IFF_EXTRA_VIDEO_SIZE);
         buf = st->codecpar->extradata;



More information about the ffmpeg-cvslog mailing list