[vlc-commits] stream_extractor: archive: reset position on failed seek

Filip Roséen git at videolan.org
Tue Jul 24 15:41:07 CEST 2018


vlc | branch: master | Filip Roséen <filip at atch.se> | Tue Jul 24 14:31:35 2018 +0200| [9399f255e779c9a5505c87c4bff0c50c6ba415e0] | committer: Jean-Baptiste Kempf

stream_extractor: archive: reset position on failed seek

The previous implementation would not reset the read position if
someone tried to seek outside the current buffer, causing the module
to signal EOF on subsequent reads, which is of course false.

These changes makes sure that we do our best to reset back to the
original position, preventing a premature EOF.

Close #20540

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9399f255e779c9a5505c87c4bff0c50c6ba415e0
---

 modules/stream_extractor/archive.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/stream_extractor/archive.c b/modules/stream_extractor/archive.c
index 8f81e592f8..a589a53f5f 100644
--- a/modules/stream_extractor/archive.c
+++ b/modules/stream_extractor/archive.c
@@ -610,6 +610,7 @@ static int archive_skip_decompressed( stream_extractor_t* p_extractor, uint64_t
 static int Seek( stream_extractor_t* p_extractor, uint64_t i_req )
 {
     private_sys_t* p_sys = p_extractor->p_sys;
+    uint64_t i_orig_offset = p_sys->i_offset;
 
     if( p_sys->b_dead )
         return VLC_EGENERIC;
@@ -645,7 +646,12 @@ static int Seek( stream_extractor_t* p_extractor, uint64_t i_req )
         }
 
         if( archive_skip_decompressed( p_extractor, i_skip ) )
+        {
+            if( archive_extractor_reset( p_extractor ) ||
+                archive_skip_decompressed( p_extractor, i_orig_offset ) )
+                msg_Err( p_extractor, "unable to reset original offset" );
             return VLC_EGENERIC;
+        }
     }
 
     p_sys->i_offset = i_req;



More information about the vlc-commits mailing list