Fix a typo in op_mem_read().
authorTimothy B. Terriberry <tterribe@xiph.org>
Sun, 27 Jan 2013 14:30:48 +0000 (06:30 -0800)
committerTimothy B. Terriberry <tterribe@xiph.org>
Sun, 27 Jan 2013 14:30:48 +0000 (06:30 -0800)
We should copy the minimum of the buffer size and the remaining
 bytes, not the maximum.
Fixes #1927.

src/stream.c

index 25a96f9..caa82f1 100644 (file)
@@ -110,7 +110,7 @@ static int op_mem_read(void *_stream,unsigned char *_ptr,int _buf_size){
   /*Check for EOF.*/
   if(pos>=size)return 0;
   /*Check for a short read.*/
-  _buf_size=(int)OP_MAX(size-pos,_buf_size);
+  _buf_size=(int)OP_MIN(size-pos,_buf_size);
   memcpy(_ptr,stream->data+pos,_buf_size);
   pos+=_buf_size;
   stream->pos=pos;