Commit c50d6fca7a for ffmpeg

commit c50d6fca7ac14271e3164a19afedcf4c58834ffb
Author: StressTestor <212606152+StressTestor@users.noreply.github.com>
Date:   Sun Oct 11 22:26:31 2026 -0600

    avformat/mpegts: stop the raw PCR readahead on a short read

    mpegts_raw_read_packet() with compute_pcr looks ahead up to
    MAX_PACKET_READAHEAD packets for the next PCR, reading 12 bytes of
    each candidate into a stack buffer with avio_read() and ignoring the
    return value. When the lookahead runs past the end of the file the
    buffer keeps whatever it held, uninitialised on the first iteration,
    and parse_pcr() is run on it. If those bytes happen to look like a
    PCR, the garbage difference becomes pcr_incr and is published as the
    duration of this packet and the pts of every later one. On a build
    with -ftrivial-auto-var-init=pattern a file ending in a partial
    packet yields duration=1716393918470 instead of 27000000.

    Stop the readahead when the seek or the read fails. The packet itself
    was already read successfully, and the "no next PCR found" fallback
    to the previous increment is the designed behaviour for this case, so
    failing the packet would be wrong.

    Same class as c2394a0ff3 (binka), 29f513af78 (fsb), 4b47405e1c (genh).

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    Signed-off-by: StressTestor <212606152+StressTestor@users.noreply.github.com>

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c013452e97..8c7df85173 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3673,8 +3673,9 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
             /* we read the next PCR (XXX: optimize it by using a bigger buffer */
             pos = avio_tell(s->pb);
             for (i = 0; i < MAX_PACKET_READAHEAD; i++) {
-                avio_seek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
-                avio_read(s->pb, pcr_buf, 12);
+                if (avio_seek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET) < 0 ||
+                    avio_read(s->pb, pcr_buf, sizeof(pcr_buf)) != sizeof(pcr_buf))
+                    break;
                 if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
                     /* XXX: not precise enough */
                     ts->pcr_incr =