Skip to content

Commit

Permalink
fix(stdlib): Ensure consistent marshal representation (#2045)
Browse files Browse the repository at this point in the history
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
  • Loading branch information
ospencer and phated committed Mar 2, 2024
1 parent 145b783 commit 029059f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/test/stdlib/marshal.test.gr
Expand Up @@ -91,3 +91,5 @@ let truncatedRecord = Bytes.slice(
)
)
assert Result.isErr(unmarshal(truncatedRecord))

assert Marshal.marshal("馃尵") == Marshal.marshal("馃尵")
5 changes: 4 additions & 1 deletion stdlib/marshal.gr
Expand Up @@ -423,8 +423,11 @@ let marshal = (value, buf) => {
@unsafe
provide let marshal = value => {
let valuePtr = fromGrain(value)
let buf = allocateBytes(size(valuePtr))
let size = size(valuePtr)
let buf = allocateBytes(size)
Memory.fill(buf + 8n, 0n, size)
marshal(valuePtr, buf + 8n)
ignore(value)
toGrain(buf): Bytes
}

Expand Down

0 comments on commit 029059f

Please sign in to comment.