From 5cddd4ccca79405ea57fcd423a554ddf12da0126 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 7 Mar 2015 09:11:47 +0100 Subject: cocoa: remove possible use after free --- video/out/cocoa_common.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 7320145193..a706467dc2 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -93,9 +93,8 @@ struct vo_cocoa_state { void (*resize_redraw)(struct vo *vo, int w, int h); }; -static void with_cocoa_lock(struct vo *vo, void(^block)(void)) +static void with_cocoa_lock(struct vo_cocoa_state *s, void(^block)(void)) { - struct vo_cocoa_state *s = vo->cocoa; cocoa_lock(s); block(); cocoa_unlock(s); @@ -103,8 +102,9 @@ static void with_cocoa_lock(struct vo *vo, void(^block)(void)) static void with_cocoa_lock_on_main_thread(struct vo *vo, void(^block)(void)) { + struct vo_cocoa_state *s = vo->cocoa; dispatch_async(dispatch_get_main_queue(), ^{ - with_cocoa_lock(vo, block); + with_cocoa_lock(s, block); }); } @@ -240,8 +240,8 @@ int vo_cocoa_init(struct vo *vo) .embedded = vo->opts->WinID >= 0, }; mpthread_mutex_init_recursive(&s->mutex); - cocoa_init_light_sensor(vo); vo->cocoa = s; + cocoa_init_light_sensor(vo); return 1; } @@ -714,7 +714,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) return vo_cocoa_ontop(vo); case VOCTRL_GET_UNFS_WINDOW_SIZE: { int *s = arg; - with_cocoa_lock(vo, ^{ + with_cocoa_lock(vo->cocoa, ^{ NSSize size = [vo->cocoa->view frame].size; s[0] = size.width; s[1] = size.height; -- cgit v1.2.3