]> git.sesse.net Git - vlc/commitdiff
stream: handle seek across EOF correctly (hopefully)
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 29 Jan 2015 17:15:53 +0000 (19:15 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 29 Jan 2015 17:16:50 +0000 (19:16 +0200)
src/input/stream.c

index ba7bcee8a8d07b2e5f0311d60a8126da0e0b000e..a5e3c22e81a8cbb8cd05f9c29833685388069362 100644 (file)
@@ -1102,15 +1102,15 @@ static int AStreamPeekStream( stream_t *s, const uint8_t **pp_peek, unsigned int
             /* Be sure we will read something */
             p_sys->stream.i_used += tk->i_start + p_sys->stream.i_offset + i_read - tk->i_end;
         }
-        if( AStreamRefillStream( s ) ) break;
-    }
-
-    if( tk->i_end < tk->i_start + p_sys->stream.i_offset + i_read )
-    {
-        i_read = tk->i_end - tk->i_start - p_sys->stream.i_offset;
+        if( AStreamRefillStream( s ) )
+        {
+            if( tk->i_end < tk->i_start + p_sys->stream.i_offset )
+                return 0; /* EOF */
+            i_read = tk->i_end - tk->i_start - p_sys->stream.i_offset;
+            break;
+        }
     }
 
-
     /* Now, direct pointer or a copy ? */
     i_off = (tk->i_start + p_sys->stream.i_offset) % STREAM_CACHE_TRACK_SIZE;
     if( i_off + i_read <= STREAM_CACHE_TRACK_SIZE )