diff options
Diffstat (limited to 'vendor/github.com/tetratelabs/wazero/internal/wasm')
3 files changed, 8 insertions, 3 deletions
diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go index 61a342ef2..8c387e9e1 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/engine.go @@ -44,9 +44,10 @@ type ModuleEngine interface { // ResolveImportedFunction is used to add imported functions needed to make this ModuleEngine fully functional. // - `index` is the function Index of this imported function. + // - `descFunc` is the type Index in Module.TypeSection of this imported function. It corresponds to Import.DescFunc. // - `indexInImportedModule` is the function Index of the imported function in the imported module. // - `importedModuleEngine` is the ModuleEngine for the imported ModuleInstance. - ResolveImportedFunction(index, indexInImportedModule Index, importedModuleEngine ModuleEngine) + ResolveImportedFunction(index, descFunc, indexInImportedModule Index, importedModuleEngine ModuleEngine) // ResolveImportedMemory is called when this module imports a memory from another module. ResolveImportedMemory(importedModuleEngine ModuleEngine) diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go index 8e072fd12..9a1f0c6d1 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go @@ -77,6 +77,7 @@ func NewMemoryInstance(memSec *Memory, allocator experimental.MemoryAllocator, m if allocator != nil { expBuffer = allocator.Allocate(capBytes, maxBytes) buffer = expBuffer.Reallocate(minBytes) + _ = buffer[:minBytes] // Bounds check that the minimum was allocated. } else if memSec.IsShared { // Shared memory needs a fixed buffer, so allocate with the maximum size. // @@ -238,12 +239,15 @@ func (m *MemoryInstance) Grow(delta uint32) (result uint32, ok bool) { return currentPages, true } - // If exceeds the max of memory size, we push -1 according to the spec. newPages := currentPages + delta if newPages > m.Max || int32(delta) < 0 { return 0, false } else if m.expBuffer != nil { buffer := m.expBuffer.Reallocate(MemoryPagesToBytesNum(newPages)) + if buffer == nil { + // Allocator failed to grow. + return 0, false + } if m.Shared { if unsafe.SliceData(buffer) != unsafe.SliceData(m.Buffer) { panic("shared memory cannot move, this is a bug in the memory allocator") diff --git a/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go b/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go index dda6e5b63..c7909c67c 100644 --- a/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go +++ b/vendor/github.com/tetratelabs/wazero/internal/wasm/store.go @@ -446,7 +446,7 @@ func (m *ModuleInstance) resolveImports(ctx context.Context, module *Module) (er return } - m.Engine.ResolveImportedFunction(i.IndexPerType, imported.Index, importedModule.Engine) + m.Engine.ResolveImportedFunction(i.IndexPerType, i.DescFunc, imported.Index, importedModule.Engine) case ExternTypeTable: expected := i.DescTable importedTable := importedModule.Tables[imported.Index] |