From 9949c1dd7834a4b15b0ae67aa1ec7b280fb068c2 Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 30 Jan 2024 17:21:56 -0300 Subject: [PATCH] avformat/avformat: fix group index range check in match_stream_specifier() Fixes segfaults when trying to map a group index with a value equal to the amount of groups in the file. Signed-off-by: James Almer --- libavformat/avformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/avformat.c b/libavformat/avformat.c index 882927f7b1..8e8c6fbe55 100644 --- a/libavformat/avformat.c +++ b/libavformat/avformat.c @@ -551,7 +551,7 @@ static int match_stream_specifier(const AVFormatContext *s, const AVStream *st, } } } - if (group_idx < 0 || group_idx > s->nb_stream_groups) + if (group_idx < 0 || group_idx >= s->nb_stream_groups) return AVERROR(EINVAL); for (unsigned j = 0; j < s->stream_groups[group_idx]->nb_streams; j++) { if (st->index == s->stream_groups[group_idx]->streams[j]->index) {