diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index 8aee89dd30..64f13e83f0 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -351,6 +351,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } + if (size > SIZE_MAX / 4) + return AVERROR(ENOMEM); + size *= 4; ptr += mod_strcspn(ptr, ",") + 1;