diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c index 270cfac389..f3ff4170c6 100644 --- a/libavformat/iamf_reader.c +++ b/libavformat/iamf_reader.c @@ -283,9 +283,9 @@ int ff_iamf_read_packet(AVFormatContext *s, IAMFDemuxContext *c, len = ff_iamf_parse_obu_header(header, size, &obu_size, &start_pos, &type, &skip_samples, &discard_padding); - if (len < 0 || obu_size > max_size) { + if (len < 0 || obu_size > max_size || len > INT_MAX - read) { av_log(s, AV_LOG_ERROR, "Failed to read obu\n"); - return len; + return len < 0 ? len : AVERROR_INVALIDDATA; } avio_seek(pb, -(size - start_pos), SEEK_CUR);