diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 80a5a565a4..82c20cab52 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -686,9 +686,11 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) int ffio_read_size(AVIOContext *s, unsigned char *buf, int size) { int ret = avio_read(s, buf, size); - if (ret != size) - return AVERROR_INVALIDDATA; - return ret; + if (ret == size) + return ret; + if (ret < 0 && ret != AVERROR_EOF) + return ret; + return AVERROR_INVALIDDATA; } int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)