Commit 37515cfd87 for ffmpeg
commit 37515cfd87561e07c5766ea04de5b1ca6f6c0a98
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Wed Oct 28 06:13:47 2026 +0100
avformat/subfile: clip the seek offsets to int64
Use av_clip64(), and clamp the end to the start when the start
lies past the end of the file, so the bounds do not cross and the size
is 0 rather than negative.
Fixes: e29016a9de
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavformat/subfile.c b/libavformat/subfile.c
index a77e477db2..dc4fe24442 100644
--- a/libavformat/subfile.c
+++ b/libavformat/subfile.c
@@ -123,18 +123,19 @@ static int64_t subfile_seek(URLContext *h, int64_t pos, int whence)
end = c->end;
if (end == INT64_MAX && (end = ffurl_seek(c->h, 0, AVSEEK_SIZE)) < 0)
return end;
+ end = FFMAX(end, c->start);
switch (whence) {
case AVSEEK_SIZE:
return end - c->start;
case SEEK_SET:
- new_pos = c->start + av_clip(pos, 0, end - c->start);
+ new_pos = c->start + av_clip64(pos, 0, end - c->start);
break;
case SEEK_CUR:
- new_pos = c->pos + av_clip(pos, -(c->pos - c->start), end - c->pos);
+ new_pos = c->pos + av_clip64(pos, -(c->pos - c->start), end - c->pos);
break;
case SEEK_END:
- new_pos = end + av_clip(pos, -(end - c->start), 0);
+ new_pos = end + av_clip64(pos, -(end - c->start), 0);
break;
default:
av_assert0(0);