diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 7a73a1791f..dc7dbb233b 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -216,6 +216,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) return offset1; offset += offset1; } + if (offset < 0) + return AVERROR(EINVAL); + offset1 = offset - pos; if (!s->must_flush && (!s->direct || !s->seek) && offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {