[FFmpeg-devel] [PATCH] Mask away AVSEEK_FORCE properly in some checks in url_fseek()

Måns Rullgård mans
Tue Mar 23 14:28:03 CET 2010


Tomas H?rdin <tomas.hardin at codemill.se> writes:

> Hi
>
> I've a bug in url_fseek(): it always returns AVERROR(EINVAL) when whence
> has AVSEEK_FORCE. The solution is to simply mask away AVSEEK_FORCE in
> the three places whence is tested for equality. Patch attached.
>
> /Tomas
>
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index da05251..b3d055d 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -136,10 +136,10 @@ int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence)
>  
>      pos = s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));
>  
> -    if (whence != SEEK_CUR && whence != SEEK_SET)
> +    if ((whence & ~AVSEEK_FORCE) != SEEK_CUR && (whence & ~AVSEEK_FORCE) != SEEK_SET)
>          return AVERROR(EINVAL);
>  
> -    if (whence == SEEK_CUR) {
> +    if ((whence & ~AVSEEK_FORCE) == SEEK_CUR) {
>          offset1 = pos + (s->buf_ptr - s->buffer);
>          if (offset == 0)
>              return offset1;

This certainly looks like it's needed.  However, I'd suggest storing
the masked value in a local variable rather than repeating the masking
all over the place.  Also, I'm not maintainer of this file.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list