From 30fd43f76598b6c70373894a7f720eee8caf9bbe Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 2 Oct 2023 15:50:02 -0700 Subject: [PATCH] Remove try/catch from intArrayFromBase64. NFC It seems like the error is strictly worse than just letting the exception propagate out. For example, we have a report of someone hitting this error but I can't tell what the root cause was: https://github.com/emscripten-core/emscripten/issues/20349 This try/catch and this error message was part of the original function back #5296 but I don't see any reason for them. --- src/base64Utils.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/base64Utils.js b/src/base64Utils.js index e05ea0af6d4ed..01a88a28bc38d 100644 --- a/src/base64Utils.js +++ b/src/base64Utils.js @@ -18,16 +18,12 @@ function intArrayFromBase64(s) { } #endif - try { - var decoded = atob(s); - var bytes = new Uint8Array(decoded.length); - for (var i = 0 ; i < decoded.length ; ++i) { - bytes[i] = decoded.charCodeAt(i); - } - return bytes; - } catch (_) { - throw new Error('Converting base64 string to bytes failed.'); + var decoded = atob(s); + var bytes = new Uint8Array(decoded.length); + for (var i = 0 ; i < decoded.length ; ++i) { + bytes[i] = decoded.charCodeAt(i); } + return bytes; } // If filename is a base64 data URI, parses and returns data (Buffer on node,