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.
This commit is contained in:
CogentRedTester 2022-05-19 16:23:49 +09:30 committed by Dudemanguy
parent f20dbcd620
commit b4c73ed105
1 changed files with 1 additions and 1 deletions

View File

@ -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