aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-09-29 00:29:39 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-09-29 00:36:24 +0200
commitcc34929da6adf64acdf5434f91a3a0cb38df76e3 (patch)
tree51d3e18ffd3cd87f84356fe45c231f0259a7d7d3
parent274204c21e421ed13c66411ce56bb70dea03d410 (diff)
off-by-one
-rw-r--r--lib/wallet/emscriptif.ts6
1 files 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);