From 1eb6cbd093481517e37b40aec174fc6f4e553bcd Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 15 Dec 2019 13:01:32 +0100 Subject: [PATCH] cocoa-cb: fix freeing of macos_opts config group using the MPContext as ta parent was a bad idea and shouldn't be done in any circumstances there because it only supposed to be for internal usage. this had the undesired effect that the options group was freed but still used since the MPContext is freed afterwards. instead manually free options group. --- osdep/macos/libmpv_helper.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osdep/macos/libmpv_helper.swift b/osdep/macos/libmpv_helper.swift index bf069efc6b..5f465370dd 100644 --- a/osdep/macos/libmpv_helper.swift +++ b/osdep/macos/libmpv_helper.swift @@ -25,6 +25,7 @@ class LibmpvHelper: LogHelper { var mpvHandle: OpaquePointer? var mpvRenderContext: OpaquePointer? + var macOptsPtr: UnsafeMutableRawPointer? var macOpts: macos_opts = macos_opts() var fbo: GLint = 1 let deinitLock = NSLock() @@ -34,18 +35,15 @@ class LibmpvHelper: LogHelper { super.init(newlog) mpvHandle = mpv - guard let mpctx = UnsafeMutablePointer(mp_client_get_core(mpvHandle)) else { - sendError("No MPContext available") - exit(1) - } guard let app = NSApp as? Application, - let ptr = mp_get_config_group(mpctx, + let ptr = mp_get_config_group(nil, mp_client_get_global(mpvHandle), app.getMacOSConf()) else { sendError("macOS config group couldn't be retrieved'") exit(1) } + macOptsPtr = ptr macOpts = UnsafeMutablePointer(OpaquePointer(ptr)).pointee } @@ -234,6 +232,8 @@ class LibmpvHelper: LogHelper { if destroy { mpv_destroy(mpvHandle) } + ta_free(macOptsPtr) + macOptsPtr = nil mpvHandle = nil log = nil }