From aea5b3dbea3fb724828e8bf039f7658d2410a8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Wed, 10 Jul 2024 20:44:15 +0200 Subject: [PATCH] player/loadfile: cancel playback cleanly if thread fails to start Currently it would crash, due to already canceled and freed resources. --- player/loadfile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/player/loadfile.c b/player/loadfile.c index 4aebc44916..8247fd62a6 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1247,6 +1247,10 @@ static void open_demux_reentrant(struct MPContext *mpctx) if (!mpctx->open_active) start_open(mpctx, url, mpctx->playing->stream_flags, false); + // If thread failed to start, cancel the playback + if (!mpctx->open_active) + goto cancel; + // User abort should cancel the opener now. mp_cancel_set_parent(mpctx->open_cancel, mpctx->playback_abort); @@ -1265,6 +1269,7 @@ static void open_demux_reentrant(struct MPContext *mpctx) mpctx->error_playing = mpctx->open_res_error; } +cancel: cancel_open(mpctx); // cleanup }