Skip to content

Commit fc4dad3

Browse files
committed
Fix HashMap initialization and insertion to handle potential errors in typed.rs
1 parent 3464cb5 commit fc4dad3

File tree

1 file changed

+2
-2
lines changed
  • crates/wasmtime/src/runtime/component/func

1 file changed

+2
-2
lines changed

crates/wasmtime/src/runtime/component/func/typed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ where
22742274
bail!("map pointer is not aligned");
22752275
}
22762276

2277-
let mut result = HashMap::with_capacity(len);
2277+
let mut result = HashMap::with_capacity(len)?;
22782278
for i in 0..len {
22792279
let entry_base = ptr + (i * tuple_size);
22802280

@@ -2287,7 +2287,7 @@ where
22872287
let value_bytes = &cx.memory()[entry_base + value_field..][..V::SIZE32];
22882288
let value = V::linear_lift_from_memory(cx, value_ty, value_bytes)?;
22892289

2290-
result.insert(key, value);
2290+
result.insert(key, value)?;
22912291
}
22922292

22932293
Ok(result)

0 commit comments

Comments
 (0)