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

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


vlc/vlc-3.0 | branch: master | Filip Roséen <filip at atch.se> | Tue Jul 24 14:31:35 2018 +0200| [a8e62c28f80e79bccd13a72c5a4b15f55ec6f888] | 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>
(cherry picked from commit 9399f255e779c9a5505c87c4bff0c50c6ba415e0)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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 7998e1dc8a..15451c9c33 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