]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/aviobuf.c
avformat/aviobuf: Allow seeking to the end of the buffer for read only buffers
[ffmpeg] / libavformat / aviobuf.c
index f374314fba8e5dd41fc9dc4f7d0473fb8c63fa6a..3d77a7ff25427b3ab08fb111fa50b9986cac0a03 100644 (file)
@@ -223,9 +223,12 @@ 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 <= buffer_size) {
+        offset1 >= 0 && offset1 <= buffer_size - s->write_flag) {
         /* can do the seek inside the buffer */
         s->buf_ptr = s->buffer + offset1;
     } else if ((!s->seekable ||