From 0ae678b0f906cde392c2c1ca8452dea96734c3b6 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 11 Sep 2017 11:49:59 +0200 Subject: [PATCH] Avoid multiple declarations in an EN_ASM({}) block Some emscripten versions don't seem to support it. --- src/libsodium/randombytes/randombytes.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libsodium/randombytes/randombytes.c b/src/libsodium/randombytes/randombytes.c index 57b46b50..708616b8 100644 --- a/src/libsodium/randombytes/randombytes.c +++ b/src/libsodium/randombytes/randombytes.c @@ -94,22 +94,22 @@ randombytes_stir(void) EM_ASM({ if (Module.getRandomValue === undefined) { try { - var window_ = 'object' === typeof window ? window : self, - crypto_ = typeof window_.crypto !== 'undefined' ? window_.crypto : window_.msCrypto, - randomValuesStandard = function() { - var buf = new Uint32Array(1); - crypto_.getRandomValues(buf); - return buf[0] >>> 0; - }; + var window_ = 'object' === typeof window ? window : self; + var crypto_ = typeof window_.crypto !== 'undefined' ? window_.crypto : window_.msCrypto; + var randomValuesStandard = function() { + var buf = new Uint32Array(1); + crypto_.getRandomValues(buf); + return buf[0] >>> 0; + }; randomValuesStandard(); Module.getRandomValue = randomValuesStandard; } catch (e) { try { - var crypto = require('crypto'), - randomValueNodeJS = function() { - var buf = crypto.randomBytes(4); - return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0; - }; + var crypto = require('crypto'); + var randomValueNodeJS = function() { + var buf = crypto.randomBytes(4); + return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0; + }; randomValueNodeJS(); Module.getRandomValue = randomValueNodeJS; } catch (e) {