off-by-one
This commit is contained in:
parent
274204c21e
commit
cc34929da6
@ -665,9 +665,9 @@ export class ByteArray extends PackedArenaObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static fromCrock(s: string, a?: Arena): ByteArray {
|
static fromCrock(s: string, a?: Arena): ByteArray {
|
||||||
let byteLength = countBytes(s) + 1;
|
let byteLength = countBytes(s);
|
||||||
let hstr = emscAlloc.malloc(byteLength);
|
let hstr = emscAlloc.malloc(byteLength + 1);
|
||||||
Module.stringToUTF8(s, hstr, byteLength);
|
Module.stringToUTF8(s, hstr, byteLength + 1);
|
||||||
let decodedLen = Math.floor((byteLength * 5) / 8);
|
let decodedLen = Math.floor((byteLength * 5) / 8);
|
||||||
let ba = new ByteArray(decodedLen, undefined, a);
|
let ba = new ByteArray(decodedLen, undefined, a);
|
||||||
let res = emsc.string_to_data(hstr, byteLength, ba.nativePtr, decodedLen);
|
let res = emsc.string_to_data(hstr, byteLength, ba.nativePtr, decodedLen);
|
||||||
|
Loading…
Reference in New Issue
Block a user