From ebc156e7c272e08e375c3e704651b179541e078b Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Mon, 8 Apr 2019 15:54:02 -0400 Subject: re-add null termination in javascript because older versions of emscripten don't support the length argument to UTF8ToString. --- javascript/olm_pre.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'javascript/olm_pre.js') diff --git a/javascript/olm_pre.js b/javascript/olm_pre.js index 7153f7a..314d7da 100644 --- a/javascript/olm_pre.js +++ b/javascript/olm_pre.js @@ -30,6 +30,14 @@ if (typeof(OLM_OPTIONS) !== 'undefined') { } } +/* The 'length' argument to Pointer_stringify doesn't work if the input + * includes characters >= 128, which makes Pointer_stringify unreliable. We + * could use it on strings which are known to be ascii, but that seems + * dangerous. Instead we add a NULL character to all of our strings and just + * use UTF8ToString. + */ +var NULL_BYTE_PADDING_LENGTH = 1; + Module['onRuntimeInitialized'] = function() { OLM_ERROR = Module['_olm_error'](); olm_exports["PRIVATE_KEY_LENGTH"] = Module['_olm_pk_private_key_length'](); -- cgit v1.2.3