From f03e673338d54b8e76b2c62c817b68f62d5f166b Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 15 Sep 2012 22:29:47 +0200 Subject: [PATCH] Fix cases where the offset is out of range (javascript parser) The exception for the "too far" error was not thrown if the offset was bigger than the buffer length, screwing up the parser. Fix #277 Signed-off-by: DTrejo --- lib/parser/javascript.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/parser/javascript.js b/lib/parser/javascript.js index dd70cf0987..9acfa1f188 100644 --- a/lib/parser/javascript.js +++ b/lib/parser/javascript.js @@ -125,12 +125,12 @@ ReplyParser.prototype._parseResult = function (type) { for (i = 0; i < packetHeader.size; i++) { ntype = this._buffer[this._offset++]; - if (this._offset === this._buffer.length) { + if (this._offset > this._buffer.length) { throw new Error("too far"); } res = this._parseResult(ntype); if (res === undefined) { - res = null; + res = null; } reply.push(res); }