aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-04-03 23:44:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-04 00:02:14 +0200
commit4d02dfbde475d249916eb19c360e890059aa6aa5 (patch)
treee9c9977480deded79b39b824a4b2e3606d5094a1
parent20ba28af945aa9bac822ce3f2d9797405fcb5d44 (diff)
downloadffmpeg-4d02dfbde475d249916eb19c360e890059aa6aa5.tar.gz
ffmpeg: Fix extradata allocation
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index d43f2e9e86..b42bb7db21 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;