Skip to content

Commit 3906e40

Browse files
committed
Fix a bug using encodeInto truncating strings
The last write accidentally wasn't accounted for in the returned length of the string and we unfortunately don't have any test coverage of `encodeInto` since it requires Firefox nightly right now (and doesn't work in Node yet). Closes #1436
1 parent d3fbf70 commit 3906e40

File tree

1 file changed

+1
-1
lines changed
  • crates/cli-support/src/js

1 file changed

+1
-1
lines changed

crates/cli-support/src/js/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,11 +1364,11 @@ impl<'a> Context<'a> {
13641364
while (true) {{
13651365
const view = getUint8Memory().subarray(ptr + writeOffset, ptr + size);
13661366
const {{ read, written }} = cachedTextEncoder.encodeInto(arg, view);
1367+
writeOffset += written;
13671368
if (read === arg.length) {{
13681369
break;
13691370
}}
13701371
arg = arg.substring(read);
1371-
writeOffset += written;
13721372
ptr = wasm.__wbindgen_realloc(ptr, size, size += arg.length * 3);
13731373
}}
13741374
WASM_VECTOR_LEN = writeOffset;

0 commit comments

Comments
 (0)