From cc34929da6adf64acdf5434f91a3a0cb38df76e3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 29 Sep 2016 00:29:39 +0200 Subject: [PATCH] off-by-one --- lib/wallet/emscriptif.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/wallet/emscriptif.ts b/lib/wallet/emscriptif.ts index 9a1d902c0..5879300e7 100644 --- 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);