From a49a44fc4b06f2675de3a4f7cbc9ac4e477f1c28 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 14 Sep 2015 19:42:28 +0200 Subject: Fix two bugs in chunk-parsing code in main.js Invert a comparison and initialize receivedLength to 0 after emptying receiveBuffer. --- web/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'web') diff --git a/web/main.js b/web/main.js index 1a299db..d2b84af 100644 --- a/web/main.js +++ b/web/main.js @@ -492,12 +492,13 @@ var connectPython = function connectPythonFunc() { receiveBuffer.push(chunk.substring(offset, i)); bodyLength = +receiveBuffer.join(''); receiveBuffer.length = 0; + receivedLength = 0; } offset = i + 1; receivingHeader = false; continue; // process the packet body in the next iteration } - else if ((receivedLength + N - offset) <= bodyLength) { + else if ((receivedLength + N - offset) >= bodyLength) { if (receivedLength == 0) { // an optimization in case the buffer is empty s = chunk.substr(offset, bodyLength); -- cgit v1.2.1