Skip to content

Commit

Permalink
gltfpack: Fix a rare IO issue with new node.js CLI
Browse files Browse the repository at this point in the history
fs.readFileSync can return a Buffer that doesn't start at the beginning
of backing ArrayBuffer. This means that to read the data correctly we
need to respect the byte offset of file.data.
  • Loading branch information
zeux committed Oct 23, 2020
1 parent 080c9fd commit e4ee7a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gltf/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ var wasi = {

var readi = Math.min(fds[fd].size - fds[fd].position, buf_len);

new Uint8Array(heap.buffer).set(new Uint8Array(fds[fd].data.buffer, fds[fd].position, readi), buf);
new Uint8Array(heap.buffer).set(fds[fd].data.subarray(fds[fd].position, fds[fd].position + readi), buf);

fds[fd].position += readi;
read += readi;
Expand Down

0 comments on commit e4ee7a0

Please sign in to comment.