Skip to content

Instantly share code, notes, and snippets.

@kaishin
Created August 5, 2015 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaishin/4bbe5acf2f5bdc956a31 to your computer and use it in GitHub Desktop.
Save kaishin/4bbe5acf2f5bdc956a31 to your computer and use it in GitHub Desktop.
#import <mach-o/dyld.h>
#import <objc/runtime.h>
#import <WebKit/WebKit.h>
@interface WKScriptMessage (WKScriptMessageLeakFix)
@end
@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];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment