From cbfadab19e17a4c50e4ddfd5599887cb0597ced5 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 10 Mar 2017 04:11:43 +0100 Subject: Fix a race condition in debug code that could lead to accessing a freed object --- .../Source/SPMySQLConnection Categories/Ping & KeepAlive.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Frameworks/SPMySQLFramework') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m index 374d0909..d46b5552 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m @@ -81,8 +81,10 @@ */ - (void)_threadedKeepAlive { - if(keepAliveThread) { - NSLog(@"warning: overwriting existing keepAliveThread: %@, results may be unpredictable!",keepAliveThread); + @synchronized(self) { + if(keepAliveThread) { + NSLog(@"warning: overwriting existing keepAliveThread: %@, results may be unpredictable!",keepAliveThread); + } } keepAliveThread = [NSThread currentThread]; @@ -114,7 +116,9 @@ keepAlivePingFailures++; } end_cleanup: - keepAliveThread = nil; + @synchronized(self) { + keepAliveThread = nil; + } } #pragma mark - -- cgit v1.2.3