From b99f78412be9b3a7aa5eb439833d6cc08a4ab4dc Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 30 Apr 2015 21:57:08 +0200 Subject: [PATCH] player: properly destroy client context if thread can't be created Minor leak in an obscure out of memory case. (cherry picked from commit d01228058b03df33a3c6be3acbf2757019a9cd83) --- player/scripting.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/player/scripting.c b/player/scripting.c index d8fbb6f84e..3747f50884 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -135,8 +135,11 @@ static void mp_load_script(struct MPContext *mpctx, const char *fname) MP_VERBOSE(arg, "Loading script %s...\n", fname); pthread_t thread; - if (pthread_create(&thread, NULL, script_thread, arg)) + if (pthread_create(&thread, NULL, script_thread, arg)) { + mpv_detach_destroy(arg->client); talloc_free(arg); + return; + } wait_loaded(mpctx); MP_VERBOSE(mpctx, "Done loading %s.\n", fname);