Typecheck the .buffer attribute before assuming it is an ArrayBuffer

This commit is contained in:
Jason Grout 2015-03-23 20:16:40 +00:00
parent aa8e36064c
commit 94724fdee1

View File

@ -79,7 +79,8 @@ define([
for (i = 0; i < msg.buffers.length; i++) {
// msg.buffers elements could be either views or ArrayBuffers
// buffers elements are ArrayBuffers
buffers.push(msg.buffers[i].buffer || msg.buffers[i])
var b = msg.buffers[i];
buffers.push(b.buffer instanceof ArrayBuffer ? b.buffer : b);
}
delete msg.buffers;
var json_utf8 = (new TextEncoder('utf8')).encode(JSON.stringify(msg));