]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
Fix a memleak when using the --use-stream-immediate option.
[vlc] / src / input / stream.c
index 567c11593e929f9617cb729bf6642f08814654b4..019e5c00dd37e238895bd846897dffcd7c1704f8 100644 (file)
@@ -512,6 +512,7 @@ static void AStreamDestroy( stream_t *s )
     vlc_object_detach( s );
 
     if( p_sys->method == Block ) block_ChainRelease( p_sys->block.p_first );
+    else if ( p_sys->method == Immediate ) free( p_sys->immediate.p_buffer );
     else free( p_sys->stream.p_buffer );
 
     free( p_sys->p_peek );
@@ -995,19 +996,21 @@ static int AStreamSeekBlock( stream_t *s, int64_t i_pos )
     }
     else
     {
-        /* Read enough data */
-        while( p_sys->block.i_start + p_sys->block.i_size < i_pos )
+        do
         {
+            /* Read and skip enough data */
             if( AStreamRefillBlock( s ) )
                 return VLC_EGENERIC;
 
             while( p_sys->block.p_current &&
-                   p_sys->i_pos + p_sys->block.p_current->i_buffer < i_pos )
+                   p_sys->i_pos + p_sys->block.p_current->i_buffer - p_sys->block.i_offset < i_pos )
             {
-                p_sys->i_pos += p_sys->block.p_current->i_buffer;
+                p_sys->i_pos += p_sys->block.p_current->i_buffer - p_sys->block.i_offset;
                 p_sys->block.p_current = p_sys->block.p_current->p_next;
+                p_sys->block.i_offset = 0;
             }
         }
+        while( p_sys->block.i_start + p_sys->block.i_size < i_pos );
 
         p_sys->block.i_offset = i_pos - p_sys->i_pos;
         p_sys->i_pos = i_pos;