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 {