[FFmpeg-cvslog] ffmpeg: Fix extradata allocation

Michael Niedermayer git at videolan.org
Tue Apr 7 13:07:35 CEST 2015


ffmpeg | branch: release/2.2 | Michael Niedermayer <michaelni at gmx.at> | Fri Apr  3 23:44:38 2015 +0200| [e63f330a1c3c0644aaec4a66c14cdacd6bf28141] | committer: Michael Niedermayer

ffmpeg: Fix extradata allocation

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 4d02dfbde475d249916eb19c360e890059aa6aa5)

Conflicts:

	ffmpeg.c

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

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

diff --git a/ffmpeg.c b/ffmpeg.c
index d566773..0fab24a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2382,11 +2382,13 @@ static int transcode_init(void)
             codec->rc_max_rate    = icodec->rc_max_rate;
             codec->rc_buffer_size = icodec->rc_buffer_size;
             codec->field_order    = icodec->field_order;
-            codec->extradata      = av_mallocz(extra_size);
-            if (!codec->extradata) {
-                return AVERROR(ENOMEM);
+            if (icodec->extradata_size) {
+                codec->extradata      = av_mallocz(extra_size);
+                if (!codec->extradata) {
+                    return AVERROR(ENOMEM);
+                }
+                memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
             }
-            memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
             codec->extradata_size= icodec->extradata_size;
             codec->bits_per_coded_sample  = icodec->bits_per_coded_sample;
 



More information about the ffmpeg-cvslog mailing list