Merge pull request #869 from Subv/ubsan

Corrected a few error cases detected by asan/ubsan
This commit is contained in:
bunnei 2018-07-31 09:24:13 -07:00 committed by GitHub
commit 3575c076cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 8 deletions

View file

@ -102,11 +102,11 @@ bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) {
if (taken) {
// Ignore the delay slot if the branch has the annul bit.
if (opcode.branch_annul) {
pc = base_address + (opcode.immediate << 2);
pc = base_address + opcode.GetBranchTarget();
return true;
}
delayed_pc = base_address + (opcode.immediate << 2);
delayed_pc = base_address + opcode.GetBranchTarget();
// Execute one more instruction due to the delay slot.
return Step(code, true);
}

View file

@ -91,6 +91,10 @@ private:
u32 GetBitfieldMask() const {
return (1 << bf_size) - 1;
}
s32 GetBranchTarget() const {
return static_cast<s32>(immediate * sizeof(u32));
}
};
union MethodAddress {