[vlc-commits] VLSub: Handle incomplete/invalid result sets without crashing

Hugo Beauzée-Luyssen git at videolan.org
Thu Dec 7 13:35:45 CET 2017


vlc/vlc-3.0 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Dec  7 13:33:41 2017 +0100| [99cfe459ba1c2da3efca68c501a0014704cac41f] | committer: Hugo Beauzée-Luyssen

VLSub: Handle incomplete/invalid result sets without crashing

(cherry picked from commit 554675f57019e2ba4863683223ccc7fc833153f1)
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=99cfe459ba1c2da3efca68c501a0014704cac41f
---

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

diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
index d8cc6b078f..e54f3273d2 100644
--- a/share/lua/extensions/VLSub.lua
+++ b/share/lua/extensions/VLSub.lua
@@ -1632,20 +1632,27 @@ function display_subtitles()
   local mainlist = input_table["mainlist"]
   mainlist:clear()
 
-  if openSub.itemStore == "0" then
-    mainlist:add_value(lang["mess_no_res"], 1)
-    setMessage("<b>"..lang["mess_complete"]..":</b> "..
-      lang["mess_no_res"])
-  elseif openSub.itemStore then
+  if not openSub.itemStore then return end
+  if openSub.itemStore ~= "0" then
+    local nbRes = 0
     for i, item in ipairs(openSub.itemStore) do
-      mainlist:add_value(
-      item.SubFileName..
-      " ["..item.SubLanguageID.."]"..
-      " ("..item.SubSumCD.." CD)", i)
+      if next(item) then
+        mainlist:add_value(
+        item.SubFileName..
+        " ["..item.SubLanguageID.."]"..
+        " ("..item.SubSumCD.." CD)", i)
+        nbRes = nbRes + 1
+      end
+    end
+    if nbRes > 0 then
+      setMessage("<b>"..lang["mess_complete"]..":</b> "..
+        #(openSub.itemStore).."  "..lang["mess_res"])
+      return
     end
-    setMessage("<b>"..lang["mess_complete"]..":</b> "..
-      #(openSub.itemStore).."  "..lang["mess_res"])
   end
+  mainlist:add_value(lang["mess_no_res"], 1)
+  setMessage("<b>"..lang["mess_complete"]..":</b> "..
+    lang["mess_no_res"])
 end
 
 function get_first_sel(list)



More information about the vlc-commits mailing list