[FFmpeg-devel] Bug in av_fifo_size?

Bill Dolson bd
Sun Nov 7 23:55:24 CET 2010


Hi,

I am about to submit some patches to read geospatial positioning data 
user private streams in Mpeg-2 TSes but I had a bug fix first.

In the older fifo implementation I believe there was a bug in av_fifo_size.

int av_fifo_size(AVFifoBuffer *f)
{
     int size = f->wptr - f->rptr;
     if (size < 0)
-        size += f->end - f->buffer;
+        size += f->end - f->buffer + 1;
     return size;
}

The current fifo implementation has read and write indexes which are 
used for the size calculation.  But what happens when they wrap around?

int av_fifo_size(AVFifoBuffer *f)
{
     return (uint32_t)(f->wndx - f->rndx);
}

Am I missing something?

If not I'll submit a patch.  Seems like the (corrected) original code is 
more safe no?

Thanks,
Bill Dolson



More information about the ffmpeg-devel mailing list