Skip to content

Commit 3ab076d

Browse files
committed
use lengthBytesUTF8() to compute the exact bytes of string
1 parent 914c241 commit 3ab076d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/utils/parseArgs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = (Core, args) => {
22
const argsPtr = Core._malloc(args.length * Uint32Array.BYTES_PER_ELEMENT);
33
args.forEach((s, idx) => {
4-
const sz = s.length*4 + 1;
4+
const sz = Core.lengthBytesUTF8(s) + 1;
55
const buf = Core._malloc(sz);
66
Core.stringToUTF8(s, buf, sz);
77
Core.setValue(argsPtr + (Uint32Array.BYTES_PER_ELEMENT * idx), buf, 'i32');

0 commit comments

Comments
 (0)