From 67d4d5f5db060fece8cc8e925f18f0a1c48813c6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 22 Feb 2015 02:15:37 +0100 Subject: [PATCH] avcodec/libtheoraenc: Check for av_fast_realloc() failure Fixes CID1257799 Signed-off-by: Michael Niedermayer --- libavcodec/libtheoraenc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index c0074af652..48f6c07aee 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -99,8 +99,11 @@ static int get_stats(AVCodecContext *avctx, int eos) return AVERROR_EXTERNAL; } if (!eos) { - h->stats = av_fast_realloc(h->stats, &h->stats_size, + void *tmp = av_fast_realloc(h->stats, &h->stats_size, h->stats_offset + bytes); + if (!tmp) + return AVERROR(ENOMEM); + h->stats = tmp; memcpy(h->stats + h->stats_offset, buf, bytes); h->stats_offset += bytes; } else {