From b2b9befad9778651d038c3ef70e026b1b4bf8dab Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 28 Jul 2022 16:54:26 -0700 Subject: [PATCH] Added alternate ArrayBufferToString() implemetation to help with stack overflow error (#4302) --- views/player.handlebars | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/views/player.handlebars b/views/player.handlebars index 37c43c39..a773ab65 100644 --- a/views/player.handlebars +++ b/views/player.handlebars @@ -1043,8 +1043,13 @@ } } + // This method has caused exceptions: https://github.com/Ylianst/MeshCentral/issues/4302 function ArrayBufferToString(buffer) { - return BinaryToString(String.fromCharCode.apply(null, Array.prototype.slice.apply(new Uint8Array(buffer)))); + try { return BinaryToString(String.fromCharCode.apply(null, Array.prototype.slice.apply(new Uint8Array(buffer)))); } catch (ex) { } + console.log('ArrayBufferToString - Unable to convert ' + buffer.byteLength + ' bytes.'); + var s = '', u = new Uint8Array(buffer); + for (var i = 0; i < buffer.byteLength; i++) { s += String.fromCharCode(u[i]); } + return s; } function StringToArrayBuffer(string) {