[vlc-commits] VLSub: Fix hash generation error handling

Hugo Beauzée-Luyssen git at videolan.org
Wed Apr 18 16:44:14 CEST 2018


vlc/vlc-3.0 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Apr 18 16:42:52 2018 +0200| [7ea161d3f2e8a914be192299291954a49e4e7511] | committer: Hugo Beauzée-Luyssen

VLSub: Fix hash generation error handling

(cherry picked from commit 914983b3fe6859dc2cfafab5bfbfb978c916eeb7)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 share/lua/extensions/VLSub.lua | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
index dd916aefb8..ee9e5f84a9 100644
--- a/share/lua/extensions/VLSub.lua
+++ b/share/lua/extensions/VLSub.lua
@@ -1297,21 +1297,24 @@ openSub = {
     local data_end = ""
     local size
     local chunk_size = 65536
+    local ok
+    local err
 
     -- Get data for hash calculation
     vlc.msg.dbg("[VLSub] Read hash data from stream")
 
     local file = vlc.stream(openSub.file.uri)
 
-    size = file:getsize()
     data_start = file:read(chunk_size)
+    ok, size = pcall(file.getsize, file)
     if not size then
-      vlc.msg.warn("[VLSub] Failed to get stream size")
+      vlc.msg.warn("[VLSub] Failed to get stream size: " .. size )
       setError(lang["mess_err_hash"])
       return false
     end
-    if not file:seek( size - chunk_size ) then
-      vlc.msg.warn("[VLSub] Failed to seek to the end of the stream")
+    ok, err = pcall(file.seek, file, size - chunk_size)
+    if not ok then
+      vlc.msg.warn("[VLSub] Failed to seek to the end of the stream: " .. err)
       setError(lang["mess_err_hash"])
       return false
     end



More information about the vlc-commits mailing list