From 3e720d2a80e00a962f2489bc4a5f54d4e84a76e9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 18 Jun 2019 13:41:38 -0700 Subject: [PATCH] Fixed potential double-free in mouse cleanup code --- src/video/cocoa/SDL_cocoamouse.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index b774626a3933e..c257be02e9657 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -348,10 +348,9 @@ + (NSCursor *)invisibleCursor Cocoa_InitMouseEventTap(mouse->driverdata); - SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; const NSPoint location = [NSEvent mouseLocation]; - driverdata->lastMoveX = location.x; - driverdata->lastMoveY = location.y; + mouse->driverdata->lastMoveX = location.x; + mouse->driverdata->lastMoveY = location.y; } void @@ -482,9 +481,10 @@ + (NSCursor *)invisibleCursor if (mouse) { if (mouse->driverdata) { Cocoa_QuitMouseEventTap(((SDL_MouseData*)mouse->driverdata)); - } - SDL_free(mouse->driverdata); + SDL_free(mouse->driverdata); + mouse->driverdata = NULL; + } } }