Skip to content

Commit 029059f

Browse files
ospencerphated
andauthored
fix(stdlib): Ensure consistent marshal representation (#2045)
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
1 parent 145b783 commit 029059f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/test/stdlib/marshal.test.gr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ let truncatedRecord = Bytes.slice(
9191
)
9292
)
9393
assert Result.isErr(unmarshal(truncatedRecord))
94+
95+
assert Marshal.marshal("🌾") == Marshal.marshal("🌾")

stdlib/marshal.gr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,11 @@ let marshal = (value, buf) => {
423423
@unsafe
424424
provide let marshal = value => {
425425
let valuePtr = fromGrain(value)
426-
let buf = allocateBytes(size(valuePtr))
426+
let size = size(valuePtr)
427+
let buf = allocateBytes(size)
428+
Memory.fill(buf + 8n, 0n, size)
427429
marshal(valuePtr, buf + 8n)
430+
ignore(value)
428431
toGrain(buf): Bytes
429432
}
430433

0 commit comments

Comments
 (0)