Changeset View
Changeset View
Standalone View
Standalone View
src/util/asmap.cpp
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | while (pos != endpos) { | ||||
if (jump == INVALID) { | if (jump == INVALID) { | ||||
// Jump offset straddles EOF | // Jump offset straddles EOF | ||||
break; | break; | ||||
} | } | ||||
if (bits == 0) { | if (bits == 0) { | ||||
// No input bits left | // No input bits left | ||||
break; | break; | ||||
} | } | ||||
if (ip[ip.size() - bits]) { | if (pos + jump < pos) { | ||||
if (jump >= endpos - pos) { | // overflow | ||||
break; | |||||
} | |||||
if (pos + jump >= endpos) { | |||||
// Jumping past EOF | // Jumping past EOF | ||||
break; | break; | ||||
} | } | ||||
if (ip[ip.size() - bits]) { | |||||
pos += jump; | pos += jump; | ||||
} | } | ||||
bits--; | bits--; | ||||
} else if (opcode == Instruction::MATCH) { | } else if (opcode == Instruction::MATCH) { | ||||
match = DecodeMatch(pos, endpos); | match = DecodeMatch(pos, endpos); | ||||
if (match == INVALID) { | if (match == INVALID) { | ||||
// Match bits straddle EOF | // Match bits straddle EOF | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | while (pos != endpos) { | ||||
prevopcode = Instruction::JUMP; | prevopcode = Instruction::JUMP; | ||||
} | } | ||||
} 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) { | if (jump == INVALID) { | ||||
// Jump offset straddles EOF | // Jump offset straddles EOF | ||||
return false; | return false; | ||||
} | } | ||||
if (jump > endpos - pos) { | if (pos + jump < pos) { | ||||
// overflow | |||||
return false; | |||||
} | |||||
if (pos + jump > endpos) { | |||||
// Jump out of range | // Jump out of range | ||||
return false; | return false; | ||||
} | } | ||||
if (bits == 0) { | if (bits == 0) { | ||||
// Consuming bits past the end of the input | // Consuming bits past the end of the input | ||||
return false; | return false; | ||||
} | } | ||||
--bits; | --bits; | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |