aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-03-08 21:08:16 +0000
committerReinhard Tartler <siretart@tauware.de>2015-05-31 10:57:50 -0400
commit891ed1184e49bc7944311302d9ece01e87c188a8 (patch)
tree5e9798ab62a97cf8f09639a3a0c5450e9768d6d2 /libavcodec
parenteaa9693fed36c29dfbac896946de31eb186ac5d0 (diff)
downloadffmpeg-891ed1184e49bc7944311302d9ece01e87c188a8.tar.gz
libvpx: Fix mixed use of av_malloc() and av_reallocp()
This buffer is resized when vpx_codec_get_cx_data() returns a VPX_CODEC_STATS_PKT packet. CC: libav-stable@libav.org Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> (cherry picked from commit 7244cefd6e6ba7258cb022dfd7a284099d88a3e8) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/libvpxenc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index dc1ddc3dc9..ba14b1d069 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -291,7 +291,7 @@ static av_cold int vpx_init(AVCodecContext *avctx,
if (enccfg.g_pass == VPX_RC_FIRST_PASS)
enccfg.g_lag_in_frames = 0;
else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
- int decode_size;
+ int decode_size, ret;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
@@ -299,12 +299,12 @@ static av_cold int vpx_init(AVCodecContext *avctx,
}
ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
- ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
- if (!ctx->twopass_stats.buf) {
+ ret = av_reallocp(&ctx->twopass_stats.buf, ctx->twopass_stats.sz);
+ if (ret < 0) {
av_log(avctx, AV_LOG_ERROR,
"Stat buffer alloc (%zu bytes) failed\n",
ctx->twopass_stats.sz);
- return AVERROR(ENOMEM);
+ return ret;
}
decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
ctx->twopass_stats.sz);