player/sub: avoid indexing arrays with -1

This commit is contained in:
Kacper Michajłow
2025-03-05 20:04:33 +01:00
parent 442e21a69c
commit dddfdf2504

View File

@@ -138,7 +138,9 @@ static bool update_subtitle(struct MPContext *mpctx, double video_pts,
// Handle displaying subtitles on terminal.
if (track->selected && track->type == STREAM_SUB && !mpctx->video_out) {
char *text = sub_get_text(dec_sub, video_pts, SD_TEXT_TYPE_PLAIN);
term_osd_set_subs(mpctx, text, get_order(mpctx, track));
int order = get_order(mpctx, track);
if (order >= 0)
term_osd_set_subs(mpctx, text, order);
talloc_free(text);
}