From ce1b7adf582f98a4b0c064a2039ea9b2479b8759 Mon Sep 17 00:00:00 2001 From: Jonathan Cohen Date: Fri, 17 Sep 2021 12:04:53 -0400 Subject: [PATCH] Correctly cast objc_msgsend calls to a function pointer with the right signature. --- CordovaLib/CordovaLib/Classes/CDVBridge.m | 3 ++- CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.m | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CordovaLib/CordovaLib/Classes/CDVBridge.m b/CordovaLib/CordovaLib/Classes/CDVBridge.m index 7ba9ec19..8fa392e9 100644 --- a/CordovaLib/CordovaLib/Classes/CDVBridge.m +++ b/CordovaLib/CordovaLib/Classes/CDVBridge.m @@ -74,7 +74,8 @@ - (void) exec:(NSString*) callbackId withService:(NSString*) service andAction:( SEL normalSelector = NSSelectorFromString(methodName); if ([obj respondsToSelector:normalSelector]) { // [obj performSelector:normalSelector withObject:command]; - objc_msgSend(obj, normalSelector, command); + // See https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html + ((void (*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command); } else { // There's no method to call, so throw an error. NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", methodName, command.cmdClassName); diff --git a/CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.m b/CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.m index 4265f0bc..6804126c 100644 --- a/CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.m +++ b/CordovaLib/CordovaLib/Classes/Commands/CDVCommandQueue.m @@ -143,7 +143,8 @@ - (BOOL) execute:(CDVInvokedUrlCommand*) command { // Test for the legacy selector first in case they both exist. if ([obj respondsToSelector:normalSelector]) { // [obj performSelector:normalSelector withObject:command]; - objc_msgSend(obj, normalSelector, command); + // See https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html + ((void (*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command); } else { // There's no method to call, so throw an error. NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", methodName, command.cmdClassName);