Skip to content

Commit

Permalink
osc.lua: fix crash when calling osc-tracklist while idle
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CogentRedTester authored and Dudemanguy committed May 19, 2022
1 parent 754bf4e commit 7c5d817
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c5d817

Please sign in to comment.