commit cc34929da6adf64acdf5434f91a3a0cb38df76e3
parent 274204c21e421ed13c66411ce56bb70dea03d410
Author: Florian Dold <florian.dold@gmail.com>
Date: Thu, 29 Sep 2016 00:29:39 +0200
off-by-one
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/wallet/emscriptif.ts b/lib/wallet/emscriptif.ts
@@ -665,9 +665,9 @@ export class ByteArray extends PackedArenaObject {
}
static fromCrock(s: string, a?: Arena): ByteArray {
- let byteLength = countBytes(s) + 1;
- let hstr = emscAlloc.malloc(byteLength);
- Module.stringToUTF8(s, hstr, byteLength);
+ let byteLength = countBytes(s);
+ let hstr = emscAlloc.malloc(byteLength + 1);
+ Module.stringToUTF8(s, hstr, byteLength + 1);
let decodedLen = Math.floor((byteLength * 5) / 8);
let ba = new ByteArray(decodedLen, undefined, a);
let res = emsc.string_to_data(hstr, byteLength, ba.nativePtr, decodedLen);