Commit 507f6dd6f7 for ffmpeg

commit 507f6dd6f775736a12a47bb87900954b0dffc2c7
Author: Richard Desmarais <richard.desmarais@gusto.com>
Date:   Thu Nov 12 10:05:56 2026 -0500

    avformat/bink: do not dereference the index in read_seek() when it is empty

    read_header() adds one index entry per frame, bounded by the frame count
    from the header, and guards the zero-frames case before touching
    index_entries[0] (bink.c:227). read_seek() has no such guard and
    dereferences index_entries[0] unconditionally, so any seek into a Bink
    file that declares zero frames (which opens fine) crashes with SIGSEGV:

        ret = avio_seek(s->pb, vsti->index_entries[0].pos + bink->smush_size, SEEK_SET);

    Reproduce with a 48-byte sample (BIK header, zero frames):
        ffmpeg -ss 1 -f bink -i poc.bik -f null -
    before: "SEGV on unknown address 0x000000000000" (ASAN), the demuxer
    keeps a NULL index when nb_frames == 0;
    after: "no index entries", AVERROR(EINVAL).

    Signed-off-by: Richard Desmarais <richard.desmarais@gusto.com>

diff --git a/libavformat/bink.c b/libavformat/bink.c
index 6becc59031..ce03adcf87 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -313,6 +313,10 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, in
     if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
         return -1;

+    /* read_header() builds no index when the frame count is zero */
+    if (!vsti->index_entries)
+        return AVERROR(EINVAL);
+
     /* seek to the first frame */
     ret = avio_seek(s->pb, vsti->index_entries[0].pos + bink->smush_size, SEEK_SET);
     if (ret < 0)