X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibtheoraenc.c;h=48f6c07aee954f697c692be1f7d76cf79c28ec8a;hb=83589e69187637d7d82d527c627b4520c92b9eac;hp=4c90822439eca4c362492ba81bfe73b41fedacee;hpb=77c133f7ac526a32fc99d4abc8313984fcfd1a82;p=ffmpeg diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 4c90822439e..48f6c07aee9 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 { @@ -131,6 +134,10 @@ static int submit_stats(AVCodecContext *avctx) } h->stats_size = strlen(avctx->stats_in) * 3/4; h->stats = av_malloc(h->stats_size); + if (!h->stats) { + h->stats_size = 0; + return AVERROR(ENOMEM); + } h->stats_size = av_base64_decode(h->stats, avctx->stats_in, h->stats_size); } while (h->stats_size - h->stats_offset > 0) {