From 0231a68ecd06cc894cc3e292a3c4cc015e40504a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 25 Dec 2011 04:48:26 +0100 Subject: [PATCH] avio: Fix ffio_limit() when due to seeking past the end less than 0 bytes remain. Signed-off-by: Michael Niedermayer (cherry picked from commit 27d323577c19af218f8a5ac33364f213b623a023) Signed-off-by: Michael Niedermayer --- libavformat/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 5ed85dc857..b59a69228e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -273,9 +273,10 @@ int ffio_limit(AVIOContext *s, int size) if(!s->maxsize || s->maxsizemaxsize= newsize; remaining= s->maxsize - avio_tell(s); + remaining= FFMAX(remaining, 0); } - if(s->maxsize>=0 && remaining>=0 && remaining+1 < size){ + if(s->maxsize>=0 && remaining+1 < size){ av_log(0, AV_LOG_ERROR, "Truncating packet of size %d to %"PRId64"\n", size, remaining+1); size= remaining+1; }