From b4c73ed10590ac7b7186f887ab1e24eeb68b35ce Mon Sep 17 00:00:00 2001 From: CogentRedTester Date: Thu, 19 May 2022 16:23:49 +0930 Subject: osc.lua: fix crash when calling osc-tracklist while idle If the player is started with --idle and the osc-tracklist script-message is called then the tracks_osc table will be nil, which caused the OSC to crash due to attempting to index a nil value. This appears to be because the osc_tracklist variable is both initialised and updated by (ultimately) the render() function, which is not run when the player is idling. Rather than mess with the existing OSC logic it's easier to either add this single check, or alternatively to initialise the the tracks_osc table somewhere before this. --- player/lua/osc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'player/lua') diff --git a/player/lua/osc.lua b/player/lua/osc.lua index cacc067c05..e1d6188814 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -367,7 +367,7 @@ end -- return a nice list of tracks of the given type (video, audio, sub) function get_tracklist(type) local msg = "Available " .. nicetypes[type] .. " Tracks: " - if #tracks_osc[type] == 0 then + if not tracks_osc or #tracks_osc[type] == 0 then msg = msg .. "none" else for n = 1, #tracks_osc[type] do -- cgit v1.2.3