Be more careful about integer overflow when computing relocs.

This commit is contained in:
Dan Gohman
2018-11-29 10:28:18 -08:00
parent f7dc961d2c
commit b7d43edfd3
2 changed files with 21 additions and 18 deletions

View File

@@ -122,8 +122,8 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
real_call_args
}
fn pointer_bytes(&self) -> usize {
usize::from(self.isa.pointer_bytes())
fn pointer_bytes(&self) -> u8 {
self.isa.pointer_bytes()
}
fn vmctx(&mut self, func: &mut Function) -> ir::GlobalValue {
@@ -405,7 +405,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
base_gv,
min_size: Imm64::new(0),
bound_gv,
element_size: Imm64::new(i64::from(self.pointer_bytes() as i64)),
element_size: Imm64::new(i64::from(self.pointer_bytes())),
index_type: I32,
})
}