From bd1866ad8a860e1b6d43c7fc988cf8c346f19f33 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Sun, 6 Oct 2024 20:53:03 +0000 Subject: update go-ffmpreg to v0.3.1 (pulls in latest wazero too) (#3398) --- vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go') 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") -- cgit v1.2.3