[vlc-commits] meta_engine: taglib: reject read on failed seek

Francois Cartegnie git at videolan.org
Tue Aug 11 13:28:08 CEST 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 10 14:38:00 2020 +0200| [837b583e4e4e531ff8b11f13300c7cbc565beb9f] | committer: Francois Cartegnie

meta_engine: taglib: reject read on failed seek

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

 modules/meta_engine/taglib.cpp | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index 9ce93e2ff9..0ab1fd3ba6 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -156,6 +156,7 @@ public:
     VlcIostream(stream_t* p_stream)
         : m_stream( p_stream )
         , m_previousPos( 0 )
+        , m_borked( false )
     {
     }
 
@@ -173,6 +174,8 @@ public:
 
     ByteVector readBlock(ulong length)
     {
+        if(m_borked)
+           return ByteVector::null;
         ByteVector res(length, 0);
         ssize_t i_read = vlc_stream_Read( m_stream, res.data(), length);
         if (i_read < 0)
@@ -209,18 +212,29 @@ public:
     void seek(long offset, Position p)
     {
         uint64_t pos = 0;
+        long len;
         switch (p)
         {
             case Current:
                 pos = m_previousPos;
                 break;
             case End:
-                pos = length();
+                len = length();
+                if(len > -1)
+                {
+                    pos = len;
+                }
+                else
+                {
+                    m_borked = true;
+                    return;
+                }
                 break;
             default:
                 break;
         }
-        if (vlc_stream_Seek( m_stream, pos + offset ) == 0)
+        m_borked = (vlc_stream_Seek( m_stream, pos + offset ) != 0);
+        if(!m_borked)
             m_previousPos = pos + offset;
     }
 
@@ -249,6 +263,7 @@ public:
 private:
     stream_t* m_stream;
     int64_t m_previousPos;
+    bool m_borked;
 };
 
 static int ExtractCoupleNumberValues( vlc_meta_t* p_meta, const char *psz_value,



More information about the vlc-commits mailing list