bang590 / JSPatch

JSPatch bridge Objective-C and Javascript using the Objective-C runtime. You can call any Objective-C class and method in JavaScript by just including a small engine. JSPatch is generally used to hotfix iOS App.
MIT License
11.37k stars 2.24k forks source link

调用super后死循环 #856

Open gopep9 opened 5 years ago

gopep9 commented 5 years ago

假如对某个对象调用其祖父类实现的函数,会在JPForwardInvocation和JPExecuteORIGForwardInvocation之间无限死循环 猜测_currInvokeSuperClsName是用于解决这个问题的,不过没有生效,应该是键值在各个函数中对不上 解决方法是把 JPForwardInvocation函数中的 _currInvokeSuperClsName[selectorName] 替换为 _currInvokeSuperClsName[JPSelectorName] 并且把callSelector中的

    if (superClassName) _currInvokeSuperClsName[selectorName] = superClassName;
    [invocation invoke];
    if (superClassName) [_currInvokeSuperClsName removeObjectForKey:selectorName];

替换为

   if(superClassName) _currInvokeSuperClsName[[NSString stringWithFormat:@"_JPSUPER_%@", selectorName]] = superClassName;
   [invocation invoke];
   if(superClassName) [_currInvokeSuperClsName removeObjectForKey:[NSString stringWithFormat:@"_JPSUPER_%@", selectorName]];