mirror of
https://github.com/revanced/smali.git
synced 2025-05-20 07:57:06 +02:00
Check for switch offset validity in the MethodAnalyzer
This commit is contained in:
parent
6429b3daa9
commit
5b2943d89b
@ -499,11 +499,19 @@ public class MethodAnalyzer {
|
|||||||
OffsetInstruction offsetInstruction = (OffsetInstruction)instruction.instruction;
|
OffsetInstruction offsetInstruction = (OffsetInstruction)instruction.instruction;
|
||||||
|
|
||||||
if (instructionOpcode == Opcode.PACKED_SWITCH || instructionOpcode == Opcode.SPARSE_SWITCH) {
|
if (instructionOpcode == Opcode.PACKED_SWITCH || instructionOpcode == Opcode.SPARSE_SWITCH) {
|
||||||
SwitchPayload switchPayload = (SwitchPayload)analyzedInstructions.get(instructionCodeAddress +
|
AnalyzedInstruction analyzedSwitchPayload = analyzedInstructions.get(
|
||||||
offsetInstruction.getCodeOffset()).instruction;
|
instructionCodeAddress + offsetInstruction.getCodeOffset());
|
||||||
|
if (analyzedSwitchPayload == null) {
|
||||||
|
throw new AnalysisException("Invalid switch payload offset");
|
||||||
|
}
|
||||||
|
SwitchPayload switchPayload = (SwitchPayload)analyzedSwitchPayload.instruction;
|
||||||
|
|
||||||
for (SwitchElement switchElement: switchPayload.getSwitchElements()) {
|
for (SwitchElement switchElement: switchPayload.getSwitchElements()) {
|
||||||
AnalyzedInstruction targetInstruction = analyzedInstructions.get(instructionCodeAddress +
|
AnalyzedInstruction targetInstruction = analyzedInstructions.get(instructionCodeAddress +
|
||||||
switchElement.getOffset());
|
switchElement.getOffset());
|
||||||
|
if (targetInstruction == null) {
|
||||||
|
throw new AnalysisException("Invalid switch target offset");
|
||||||
|
}
|
||||||
|
|
||||||
addPredecessorSuccessor(instruction, targetInstruction, exceptionHandlers,
|
addPredecessorSuccessor(instruction, targetInstruction, exceptionHandlers,
|
||||||
instructionsToProcess);
|
instructionsToProcess);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user