From d7c5fc6d6e8d7fa6346371eb2051a4a235d4338a Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Fri, 17 Sep 2010 15:35:26 -0700 Subject: [PATCH] Fixed zero-length mutlibulk replies --- index.js | 3 +++ test.js | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 71c2553a96..f23fbf9807 100644 --- a/index.js +++ b/index.js @@ -118,6 +118,9 @@ RedisReplyParser.prototype.execute = function (incoming_buf) { this.multi_bulk_length = parseInt(small_toString(this.tmp_buffer), 10); this.multi_bulk_replies = []; this.state = "type"; + if (0 == this.multi_bulk_length) { + this.send_reply([]); + } } else { this.emit("error", new Error("didn't see LF after NL reading multi bulk count")); this.state = "type"; // try to start over with next data chunk diff --git a/test.js b/test.js index e0622bfaab..2e60c97230 100644 --- a/test.js +++ b/test.js @@ -209,10 +209,10 @@ tests.KEYS = function () { }); }; -tests.KEYS_EMPTY = function () { - var name = "KEYS_EMPTY"; +tests.MULTIBULK_ZERO_LENGTH = function () { + var name = "MULTIBULK_ZERO_LENGTH"; client.KEYS(['users:*'], function(err, results){ - assert.strictEqual(null, err, 'error on empty KEYS'); + assert.strictEqual(null, err, 'error on empty multibulk reply'); assert.strictEqual(0, results.length); next(name); });