Added alternate ArrayBufferToString() implemetation to help with stack overflow error (#4302)
Ylian Saint-Hilaire committed
Jul 28, 2022 at 16:54 UTC
b2b9befad9778651d038c3ef70e026b1b4bf8dab
1 file changed
+6
-1
views/player.handlebars
+6
-1
@@ -1043,8 +1043,13 @@
1043
}
1044
}
1045
1046
+ // This method has caused exceptions: https://github.com/Ylianst/MeshCentral/issues/4302
1047
function ArrayBufferToString(buffer) {
1047
- return BinaryToString(String.fromCharCode.apply(null, Array.prototype.slice.apply(new Uint8Array(buffer))));
1048
+ try { return BinaryToString(String.fromCharCode.apply(null, Array.prototype.slice.apply(new Uint8Array(buffer)))); } catch (ex) { }
1049
+ console.log('ArrayBufferToString - Unable to convert ' + buffer.byteLength + ' bytes.');
1050
+ var s = '', u = new Uint8Array(buffer);
1051
+ for (var i = 0; i < buffer.byteLength; i++) { s += String.fromCharCode(u[i]); }
1052
+ return s;
1053
}
1054
1055
function StringToArrayBuffer(string) {