Commit 9a688ce884 for ffmpeg

commit 9a688ce884b5073ff2e87077a3792d219dba3d7a
Author: Hongduo Zhao <hdzhao214@gmail.com>
Date:   Tue Sep 29 01:57:32 2026 +0200

    avformat/seek: reject out of range stream indexes in av_seek_frame()

    This is hardening against API misuse; a caller passing such an index is
    the bug, see the amovie "seek" command fix for CHE5mlmUNamc.

    Found-by: Hongduo Zhao

diff --git a/libavformat/seek.c b/libavformat/seek.c
index c0d94371e6..31e3e6dd69 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -643,6 +643,9 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
 {
     int ret;

+    if (stream_index < -1 || stream_index >= (int)s->nb_streams)
+        return AVERROR(EINVAL);
+
     if (ffifmt(s->iformat)->read_seek2 && !ffifmt(s->iformat)->read_seek) {
         int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
         if ((flags & AVSEEK_FLAG_BACKWARD))