]> git.sesse.net Git - vlc/commitdiff
Fixed a huge regression in block_FifoPut.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 30 Jan 2010 11:54:21 +0000 (12:54 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 30 Jan 2010 12:12:27 +0000 (13:12 +0100)
It was broken as soon as a linked list of buffers was pushed.

src/misc/block.c

index 433c742d85975a0af4a390c1ec571175466691dc..1d06fec1467f52d47116daecc8c1d86a11b3d6e3 100644 (file)
@@ -571,18 +571,21 @@ void block_FifoPace (block_fifo_t *fifo, size_t max_depth, size_t max_size)
 size_t block_FifoPut( block_fifo_t *p_fifo, block_t *p_block )
 {
     size_t i_size = 0, i_depth = 0;
+    block_t *p_last;
 
     if (p_block == NULL)
         return 0;
-    for (block_t *b = p_block; b != NULL; b = b->p_next)
+    for (p_last = p_block; ; p_last = p_last->p_next)
     {
-        i_size += b->i_buffer;
+        i_size += p_last->i_buffer;
         i_depth++;
+        if (!p_last->p_next)
+            break;
     }
 
     vlc_mutex_lock (&p_fifo->lock);
     *p_fifo->pp_last = p_block;
-    p_fifo->pp_last = &p_block->p_next;
+    p_fifo->pp_last = &p_last->p_next;
     p_fifo->i_depth += i_depth;
     p_fifo->i_size += i_size;
     /* We queued at least one block: wake up one read-waiting thread */