From e731972163db1e00b3408692c88226ea3bf00814 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Thu, 4 Apr 2024 07:56:21 -0400 Subject: [PATCH] dec_sub: fix locking for sub_is_{primary,secondary}_visible These public functions should use locks to keep its usage consistent with input.c. Fixes: 024e0cd4c1405a41edd6a8b302ec6b747bc60ea3 --- sub/dec_sub.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 94ff3ba4dd..dab5abc69a 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -548,10 +548,16 @@ void sub_set_play_dir(struct dec_sub *sub, int dir) bool sub_is_primary_visible(struct dec_sub *sub) { - return sub->shared_opts->sub_visibility[0]; + mp_mutex_lock(&sub->lock); + bool ret = sub->shared_opts->sub_visibility[0]; + mp_mutex_unlock(&sub->lock); + return ret; } bool sub_is_secondary_visible(struct dec_sub *sub) { - return sub->shared_opts->sub_visibility[1]; + mp_mutex_lock(&sub->lock); + bool ret = sub->shared_opts->sub_visibility[1]; + mp_mutex_unlock(&sub->lock); + return ret; }