Skip to content

Commit

Permalink
fix(stdlib): Fix overzealous Memory.fill in Buffer.truncate (#1781)
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Mar 28, 2023
1 parent a28ebb4 commit e1f24e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/buffer.gr
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ provide let reset = buffer => {
provide let truncate = (length, buffer) => {
if (length < 0 || length > buffer.len) throw IndexOutOfBounds

from WasmI32 use { add as (+) }
from WasmI32 use { add as (+), sub as (-) }
let src = WasmI32.fromGrain(buffer.data)
let size = getSize(src)
let off = coerceNumberToWasmI32(length)
let ret = Memory.fill(src + _VALUE_OFFSET + off, 0n, size)
let ret = Memory.fill(src + _VALUE_OFFSET + off, 0n, size - off)
buffer.len = length
}

Expand Down

0 comments on commit e1f24e9

Please sign in to comment.