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

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


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

VLSub: Fix hash generation error handling

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

 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