Skip to content

Commit 0c681ee

Browse files
committed
Fix offset to arg comparison
1 parent 7418cec commit 0c681ee

File tree

1 file changed

+3
-5
lines changed
  • crates/cli-support/src/js

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,10 +1464,7 @@ impl<'a> Context<'a> {
14641464
const mem = getUint8Memory();
14651465
for (; offset < arg.length; offset++) {{
14661466
const code = arg.charCodeAt(offset);
1467-
if (code > 0x7F) {{
1468-
arg = arg.slice(offset);
1469-
break;
1470-
}}
1467+
if (code > 0x7F) break;
14711468
mem[ptr + offset] = code;
14721469
}}
14731470
}}
@@ -1481,7 +1478,7 @@ impl<'a> Context<'a> {
14811478
"
14821479
{}
14831480
if (offset !== arg.length) {{
1484-
const buf = cachedTextEncoder.encode(arg);
1481+
const buf = cachedTextEncoder.encode(arg.slice(offset));
14851482
ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + buf.length);
14861483
getUint8Memory().set(buf, ptr + offset);
14871484
offset += buf.length;
@@ -1499,6 +1496,7 @@ impl<'a> Context<'a> {
14991496
"
15001497
{}
15011498
if (offset !== arg.length) {{
1499+
arg = arg.slice(offset);
15021500
ptr = wasm.__wbindgen_realloc(ptr, size, size = offset + arg.length * 3);
15031501
const view = getUint8Memory().subarray(ptr + offset, ptr + size);
15041502
offset += cachedTextEncoder.encodeInto(arg, view).written;

0 commit comments

Comments
 (0)