Skip to content

Commit be16d78

Browse files
Fix out-of-range access of local types in the translator
1 parent 7505f0a commit be16d78

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sources/WasmKit/Translator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ struct InstructionTranslator: InstructionVisitor {
378378
let types: [ValueType]
379379

380380
func type(of localIndex: UInt32) throws -> ValueType {
381+
guard Int(localIndex) < types.count else {
382+
throw TranslationError("Local index \(localIndex) is out of range")
383+
}
381384
return self.types[Int(localIndex)]
382385
}
383386
}

0 commit comments

Comments
 (0)