Permalink
Browse files

Fix memory leak

  • Loading branch information...
bang bang
bang authored and bang committed Sep 25, 2015
1 parent 799d70c commit 5d5208668b9d287df971966034680426572aae96
Showing with 6 additions and 1 deletion.
  1. +6 −1 JSPatch/JPEngine.m
View
@@ -296,9 +296,13 @@ static void setPropIMP(id slf, SEL selector, id val, NSString *propName) {
struct objc_method_description *methods = protocol_copyMethodDescriptionList(protocol, isRequired, isInstanceMethod, &selCount);
for (int i = 0; i < selCount; i ++) {
if ([selectorName isEqualToString:NSStringFromSelector(methods[i].name)]) {
return methods[i].types;
char *types = malloc(strlen(methods[i].types) + 1);
strcpy(types, methods[i].types);
free(methods);
return types;
}
}
free(methods);
return NULL;
}
@@ -361,6 +365,7 @@ static void setPropIMP(id slf, SEL selector, id val, NSString *propName) {
if (!types) types = methodTypesInProtocol(protocolName, selectorName, isInstance, NO);
if (types) {
overrideMethod(currCls, selectorName, jsMethod, !isInstance, types);
free(types);
overrided = YES;
break;
}

0 comments on commit 5d52086

Please sign in to comment.