Skip to content

Commit

Permalink
Fix a missing early-return in Table::get (#1652)
Browse files Browse the repository at this point in the history
Turns out this was a typo from #1016!
  • Loading branch information
alexcrichton authored May 4, 2020
1 parent d6796d0 commit 6ef106f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/api/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub(crate) fn from_checked_anyfunc(
store: &Store,
) -> Val {
if item.type_index == wasmtime_runtime::VMSharedSignatureIndex::default() {
Val::AnyRef(AnyRef::Null);
return Val::AnyRef(AnyRef::Null);
}
let instance_handle = unsafe { wasmtime_runtime::InstanceHandle::from_vmctx(item.vmctx) };
let export = wasmtime_runtime::ExportFunction {
Expand Down
1 change: 1 addition & 0 deletions tests/all/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod linker;
mod memory_creator;
mod name;
mod stack_overflow;
mod table;
mod traps;
mod use_after_drop;
mod wast;
13 changes: 13 additions & 0 deletions tests/all/table.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use wasmtime::*;

#[test]
fn get_none() {
let store = Store::default();
let ty = TableType::new(ValType::FuncRef, Limits::new(1, None));
let table = Table::new(&store, ty, Val::AnyRef(AnyRef::Null)).unwrap();
match table.get(0) {
Some(Val::AnyRef(AnyRef::Null)) => {}
_ => panic!(),
}
assert!(table.get(1).is_none());
}

0 comments on commit 6ef106f

Please sign in to comment.