mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-07 05:31:03 +02:00
refactor: Rework asmap Interpret to avoid ptrdiff_t
This commit is contained in:
parent
df37377e30
commit
eac6a3080d
@ -93,7 +93,8 @@ uint32_t Interpret(const std::vector<bool> &asmap, const std::vector<bool> &ip)
|
|||||||
jump = DecodeJump(pos, endpos);
|
jump = DecodeJump(pos, endpos);
|
||||||
if (jump == INVALID) break; // Jump offset straddles EOF
|
if (jump == INVALID) break; // Jump offset straddles EOF
|
||||||
if (bits == 0) break; // No input bits left
|
if (bits == 0) break; // No input bits left
|
||||||
if (jump >= endpos - pos) break; // Jumping past EOF
|
if (pos + jump < pos) break; // overflow
|
||||||
|
if (pos + jump >= endpos) break; // Jumping past EOF
|
||||||
if (ip[ip.size() - bits]) {
|
if (ip[ip.size() - bits]) {
|
||||||
pos += jump;
|
pos += jump;
|
||||||
}
|
}
|
||||||
@ -155,7 +156,8 @@ bool SanityCheckASMap(const std::vector<bool>& asmap, int bits)
|
|||||||
} else if (opcode == Instruction::JUMP) {
|
} else if (opcode == Instruction::JUMP) {
|
||||||
uint32_t jump = DecodeJump(pos, endpos);
|
uint32_t jump = DecodeJump(pos, endpos);
|
||||||
if (jump == INVALID) return false; // Jump offset straddles EOF
|
if (jump == INVALID) return false; // Jump offset straddles EOF
|
||||||
if (jump > endpos - pos) return false; // Jump out of range
|
if (pos + jump < pos) return false; // overflow
|
||||||
|
if (pos + jump > endpos) return false; // Jump out of range
|
||||||
if (bits == 0) return false; // Consuming bits past the end of the input
|
if (bits == 0) return false; // Consuming bits past the end of the input
|
||||||
--bits;
|
--bits;
|
||||||
uint32_t jump_offset = pos - begin + jump;
|
uint32_t jump_offset = pos - begin + jump;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user