fix: current must be calculated after increment

This commit is contained in:
Lucaskyy 2022-03-20 16:57:33 +01:00
parent ec8115f3ac
commit 5f12bab5df
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89

View file

@ -104,9 +104,9 @@ private fun InsnList.scanFor(pattern: Array<Int>): ScanResult {
for (i in 0 until this.size()) {
var occurrence = 0
while (i + occurrence < this.size()) {
val current = i + occurrence
if (this[current].opcode != pattern[occurrence]) break
if (this[i + occurrence].opcode != pattern[occurrence]) break
if (++occurrence >= pattern.size) {
val current = i + occurrence
return ScanResult(true, current - pattern.size, current)
}
}