diff fifo.c @ 511:5accd0bccc76 libavutil

Ensure that one can store X bytes in a fifo of size X. Fixed issue417.
author michael
date Sun, 25 May 2008 23:04:09 +0000
parents b7593ce78422
children a1ac1cb9a91b
line wrap: on
line diff
--- a/fifo.c	Sun May 25 22:20:39 2008 +0000
+++ b/fifo.c	Sun May 25 23:04:09 2008 +0000
@@ -22,8 +22,9 @@
 #include "common.h"
 #include "fifo.h"
 
-int av_fifo_init(AVFifoBuffer *f, int size)
+int av_fifo_init(AVFifoBuffer *f, unsigned int size)
 {
+    size= FFMAX(size, size+1);
     f->wptr = f->rptr =
     f->buffer = av_malloc(size);
     f->end = f->buffer + size;
@@ -56,7 +57,7 @@
 void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
     unsigned int old_size= f->end - f->buffer;
 
-    if(old_size < new_size){
+    if(old_size <= new_size){
         int len= av_fifo_size(f);
         AVFifoBuffer f2;