Merge pull request #1442 from alexcrichton/fix-encode-into

Fix a bug using `encodeInto` truncating strings
This commit is contained in:
Alex Crichton 2019-04-11 09:34:16 -05:00 committed by GitHub
commit 560cb022ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1364,11 +1364,11 @@ impl<'a> Context<'a> {
while (true) {{
const view = getUint8Memory().subarray(ptr + writeOffset, ptr + size);
const {{ read, written }} = cachedTextEncoder.encodeInto(arg, view);
writeOffset += written;
if (read === arg.length) {{
break;
}}
arg = arg.substring(read);
writeOffset += written;
ptr = wasm.__wbindgen_realloc(ptr, size, size += arg.length * 3);
}}
WASM_VECTOR_LEN = writeOffset;