summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-05-25 23:04:09 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-05-25 23:04:09 +0000
commitfa3b98182d711f7735da6e820f90fbcf96cae4d7 (patch)
tree7626aa54c7b0af1b68ada2dfbaabd46c96ec2f1c /libavutil
parent0871ae1a930122f7124358a0ce3caf81876913a9 (diff)
Ensure that one can store X bytes in a fifo of size X.
Fixed issue417. Originally committed as revision 13405 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/fifo.c5
-rw-r--r--libavutil/fifo.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index f2ace514bd..eda3558436 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -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 @@ int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size)
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;
diff --git a/libavutil/fifo.h b/libavutil/fifo.h
index f5fb144211..6533be921d 100644
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -38,7 +38,7 @@ typedef struct AVFifoBuffer {
* @param size of FIFO
* @return <0 for failure >=0 otherwise
*/
-int av_fifo_init(AVFifoBuffer *f, int size);
+int av_fifo_init(AVFifoBuffer *f, unsigned int size);
/**
* Frees an AVFifoBuffer.