Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Use `try_new` for `Box` allocation in `Memory::new_static` (#13377)

Nick Fitzgerald4bbfe54b8c22
diff --git a/crates/wasmtime/src/runtime/vm/memory.rs b/crates/wasmtime/src/runtime/vm/memory.rs
index 4b24653f87..fce3c4afa0 100644
--- a/crates/wasmtime/src/runtime/vm/memory.rs
+++ b/crates/wasmtime/src/runtime/vm/memory.rs
@@ -271,7 +271,7 @@ impl Memory {
) -> Result<Self> {
let (minimum, maximum) = Self::limit_new(ty, limiter).await?;
let pooled_memory = StaticMemory::new(base, base_capacity, minimum, maximum)?;
- let allocation = Box::new(pooled_memory);
+ let allocation = try_new::<Box<_>>(pooled_memory)?;
// Configure some defaults a bit differently for this memory within the
// `LocalMemory` structure created, notably we already have