Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#import <mach-o/dyld.h>
#import <objc/runtime.h>
#import <WebKit/WebKit.h>
@interface WKScriptMessage (WKScriptMessageLeakFix)
@implementation WKScriptMessage (WKScriptMessageLeakFix)
+ (void)load {
int32_t version = NSVersionOfRunTimeLibrary("WebKit");
int32_t majorVersion = version >> 16;
if (majorVersion > 600) return;
Method fixedDealloc = class_getInstanceMethod(self, @selector(fixedDealloc));
IMP fixedDeallocIMP = method_getImplementation(fixedDealloc);
class_addMethod(self, @selector(dealloc), fixedDeallocIMP, method_getTypeEncoding(fixedDealloc));
- (void)fixedDealloc {
[self.body release];
[super dealloc];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.