Skip to content

Commit

Permalink
wazevo: fixes newAlignedOpaque not to use unsafe (tetratelabs#2043)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake authored Feb 12, 2024
1 parent 392dcf7 commit 184a6a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/engine/wazevo/module_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ func newAlignedOpaque(size int) moduleContextOpaque {
if size%16 != 0 {
panic("size must be a multiple of 16")
}
type _16 [16]byte
buf := make([]_16, size/16)
slice := unsafe.Slice(&buf[0][0], size)
return *(*moduleContextOpaque)(&slice)
buf := make([]byte, size+16)
// Align the buffer to 16 bytes.
rem := uintptr(unsafe.Pointer(&buf[0])) % 16
buf = buf[16-rem:]
return buf
}

func putLocalMemory(opaque []byte, offset wazevoapi.Offset, mem *wasm.MemoryInstance) {
Expand Down

0 comments on commit 184a6a0

Please sign in to comment.