[core] Check cast before returning from hooker (#696)
This commit is contained in:
parent
efa42a4eb0
commit
a694d2bc73
|
|
@ -20,17 +20,17 @@
|
|||
|
||||
package de.robv.android.xposed;
|
||||
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
public class LspHooker {
|
||||
private final XposedBridge.AdditionalHookInfo additionalInfo;
|
||||
private final Member method;
|
||||
private final Executable method;
|
||||
private final Method backup;
|
||||
|
||||
public LspHooker(XposedBridge.AdditionalHookInfo info, Member origin, Method backup) {
|
||||
public LspHooker(XposedBridge.AdditionalHookInfo info, Executable origin, Method backup) {
|
||||
this.additionalInfo = info;
|
||||
this.method = origin;
|
||||
this.backup = backup;
|
||||
|
|
@ -118,8 +118,15 @@ public class LspHooker {
|
|||
// return
|
||||
if (param.hasThrowable())
|
||||
throw param.getThrowable();
|
||||
else
|
||||
return param.getResult();
|
||||
else {
|
||||
var result = param.getResult();
|
||||
if (method instanceof Method) {
|
||||
var returnType = ((Method) method).getReturnType();
|
||||
if (!returnType.isPrimitive())
|
||||
return returnType.cast(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue