[FFmpeg-cvslog] ffmpeg: Fix extradata allocation

Michael Niedermayer git at videolan.org
Sat Apr 4 00:47:38 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Apr  3 23:44:38 2015 +0200| [4d02dfbde475d249916eb19c360e890059aa6aa5] | committer: Michael Niedermayer

ffmpeg: Fix extradata allocation

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

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

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

diff --git a/ffmpeg.c b/ffmpeg.c
index d43f2e9..b42bb7d 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2684,11 +2684,13 @@ static int transcode_init(void)
             enc_ctx->rc_max_rate    = dec_ctx->rc_max_rate;
             enc_ctx->rc_buffer_size = dec_ctx->rc_buffer_size;
             enc_ctx->field_order    = dec_ctx->field_order;
-            enc_ctx->extradata      = av_mallocz(extra_size);
-            if (!enc_ctx->extradata) {
-                return AVERROR(ENOMEM);
+            if (dec_ctx->extradata_size) {
+                enc_ctx->extradata      = av_mallocz(extra_size);
+                if (!enc_ctx->extradata) {
+                    return AVERROR(ENOMEM);
+                }
+                memcpy(enc_ctx->extradata, dec_ctx->extradata, dec_ctx->extradata_size);
             }
-            memcpy(enc_ctx->extradata, dec_ctx->extradata, dec_ctx->extradata_size);
             enc_ctx->extradata_size= dec_ctx->extradata_size;
             enc_ctx->bits_per_coded_sample  = dec_ctx->bits_per_coded_sample;
 



More information about the ffmpeg-cvslog mailing list