Skip to content

Commit 060fc7b

Browse files
av8taav8taospencer
authored
fix(stdlib): Remove memory corruption in File.fdReaddir (#1573)
Co-authored-by: av8ta <av8ta@pm.me> Co-authored-by: Oscar Spencer <oscar@grain-lang.org>
1 parent 925b51d commit 060fc7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/sys/file.gr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,9 +1128,9 @@ export let fdReaddir = (fd: FileDescriptor) => {
11281128

11291129
let filetype = filetypeFromNumber(WasmI32.load8U(ent, 20n))
11301130

1131-
let dirent = { inode, path, filetype }
1131+
let dirent = WasmI32.fromGrain({ inode, path, filetype })
11321132

1133-
WasmI32.store(arr + i * 4n, WasmI32.fromGrain(dirent), 8n)
1133+
WasmI32.store(arr + i * 4n, Memory.incRef(dirent), 8n)
11341134

11351135
let next = WasmI32.load(bufs, 4n)
11361136
Memory.free(bufs)

0 commit comments

Comments
 (0)