diff options
author | 2024-10-06 20:53:03 +0000 | |
---|---|---|
committer | 2024-10-06 20:53:03 +0000 | |
commit | bd1866ad8a860e1b6d43c7fc988cf8c346f19f33 (patch) | |
tree | 6726f95b30b73baa4e5a7feed5c0b41bf46116db /vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go | |
parent | [chore/themes] Tweak colors on new themes (#3397) (diff) | |
download | gotosocial-bd1866ad8a860e1b6d43c7fc988cf8c346f19f33.tar.xz |
update go-ffmpreg to v0.3.1 (pulls in latest wazero too) (#3398)
Diffstat (limited to 'vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go')
-rw-r--r-- | vendor/github.com/tetratelabs/wazero/internal/wasm/memory.go | 6 |
1 files changed, 5 insertions, 1 deletions
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") |