mirror of
https://github.com/revanced/smali.git
synced 2025-06-12 04:17:36 +02:00
Implemented verification for throw
git-svn-id: https://smali.googlecode.com/svn/trunk@578 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -466,6 +466,8 @@ public class MethodAnalyzer {
|
||||
return handleFilledNewArrayRange(analyzedInstruction);
|
||||
case FILL_ARRAY_DATA:
|
||||
return handleFillArrayData(analyzedInstruction);
|
||||
case THROW:
|
||||
return handleThrow(analyzedInstruction);
|
||||
}
|
||||
assert false;
|
||||
return false;
|
||||
@ -1131,6 +1133,35 @@ public class MethodAnalyzer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean handleThrow(AnalyzedInstruction analyzedInstruction) {
|
||||
int register = ((SingleRegisterInstruction)analyzedInstruction.instruction).getRegisterA();
|
||||
|
||||
RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(register);
|
||||
assert registerType != null;
|
||||
|
||||
if (registerType.category == RegisterType.Category.Unknown) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (registerType.category == RegisterType.Category.Null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (registerType.category != RegisterType.Category.Reference) {
|
||||
throw new ValidationException(String.format("Cannot use throw with non-reference type %s in register v%d",
|
||||
registerType.toString(), register));
|
||||
}
|
||||
|
||||
assert registerType.type != null;
|
||||
|
||||
if (!registerType.type.extendsClass(ClassPath.getClassDef("Ljava/lang/Throwable;"))) {
|
||||
throw new ValidationException(String.format("Cannot use throw with non-throwable type %s in register v%d",
|
||||
registerType.type.getClassType(), register));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void checkRegister(RegisterType registerType, EnumSet validCategories) {
|
||||
if (!validCategories.contains(registerType.category)) {
|
||||
//TODO: add expected categories to error message
|
||||
|
Reference in New Issue
Block a user