From c674d8dc1b312a80a98b9352fcabd81dbaac33bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 Aug 2025 18:15:19 +0000 Subject: [PATCH] Fix SAT>IP multi-client unsubscribe crash by checking remaining subscriptions Co-authored-by: Flole998 <9951871+Flole998@users.noreply.github.com> --- src/subscriptions.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/subscriptions.c b/src/subscriptions.c index 08f490e1d..4b31f53f6 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -28,6 +28,9 @@ #include "atomic.h" #include "input.h" #include "intlconv.h" +#if ENABLE_MPEGTS +#include "input/mpegts.h" +#endif #include "dbus.h" struct th_subscription_list subscriptions; @@ -710,8 +713,18 @@ subscription_unsubscribe(th_subscription_t *s, int flags) #if ENABLE_MPEGTS if (raw && t == raw) { + mpegts_service_t *ms = (mpegts_service_t *)raw; + mpegts_mux_t *mm = ms->s_dvb_mux; LIST_REMOVE(s, ths_mux_link); - service_remove_raw(raw); + /* Only remove raw service if no other subscriptions are using it */ + if (LIST_EMPTY(&mm->mm_raw_subs)) { + tvhdebug(LS_SUBSCRIPTION, "%04X: removing raw service - no remaining subscriptions", + shortid(s)); + service_remove_raw(raw); + } else { + tvhdebug(LS_SUBSCRIPTION, "%04X: keeping raw service - other subscriptions still active", + shortid(s)); + } } #endif -- 2.47.3