From 668dfdead6436a0ea9e91fa6d401ea5cd57f5cc1 Mon Sep 17 00:00:00 2001 From: Jerry Sievert Date: Tue, 11 Sep 2012 11:43:18 -0700 Subject: [PATCH] fix null key response: issue #267 --- lib/parser/javascript.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/parser/javascript.js b/lib/parser/javascript.js index 3a69a574e5..b2d6cb2387 100644 --- a/lib/parser/javascript.js +++ b/lib/parser/javascript.js @@ -74,7 +74,7 @@ ReplyParser.prototype._parseResult = function (type) { // packets with a size of -1 are considered null if (packetHeader.size === -1) { - return null; + return undefined; } end = this._offset + packetHeader.size; @@ -108,7 +108,7 @@ ReplyParser.prototype._parseResult = function (type) { } var reply = [ ]; - var ntype, i; + var ntype, i, res; offset = this._offset - 1; @@ -118,7 +118,11 @@ ReplyParser.prototype._parseResult = function (type) { if (this._offset === this._buffer.length) { throw new Error("too far"); } - reply.push(this._parseResult(ntype)); + res = this._parseResult(ntype); + if (res === undefined) { + res = null; + } + reply.push(res); } return reply; @@ -171,6 +175,12 @@ ReplyParser.prototype.execute = function (buffer) { break; } + // check the state for what is the result of + // a -1, set it back up for a null reply + if (ret === undefined) { + ret = null; + } + this.send_reply(ret); } else if (type === 42) { // * // set a rewind point. if a failure occurs,