mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 14:12:13 +00:00
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
This commit is contained in:
parent
d3fbf707e1
commit
3906e4066d
@ -1364,11 +1364,11 @@ impl<'a> Context<'a> {
|
|||||||
while (true) {{
|
while (true) {{
|
||||||
const view = getUint8Memory().subarray(ptr + writeOffset, ptr + size);
|
const view = getUint8Memory().subarray(ptr + writeOffset, ptr + size);
|
||||||
const {{ read, written }} = cachedTextEncoder.encodeInto(arg, view);
|
const {{ read, written }} = cachedTextEncoder.encodeInto(arg, view);
|
||||||
|
writeOffset += written;
|
||||||
if (read === arg.length) {{
|
if (read === arg.length) {{
|
||||||
break;
|
break;
|
||||||
}}
|
}}
|
||||||
arg = arg.substring(read);
|
arg = arg.substring(read);
|
||||||
writeOffset += written;
|
|
||||||
ptr = wasm.__wbindgen_realloc(ptr, size, size += arg.length * 3);
|
ptr = wasm.__wbindgen_realloc(ptr, size, size += arg.length * 3);
|
||||||
}}
|
}}
|
||||||
WASM_VECTOR_LEN = writeOffset;
|
WASM_VECTOR_LEN = writeOffset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user