From a93020c555d26252d49fd9f74422898ac18c894d Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Mon, 20 Sep 2010 07:32:45 -0700 Subject: [PATCH] Fixed null HGETALL bug causing exception --- index.js | 2 +- test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9b699141ec..73d2af16f0 100644 --- a/index.js +++ b/index.js @@ -436,7 +436,7 @@ RedisClient.prototype.return_reply = function (reply) { if (command_obj) { if (typeof command_obj.callback === "function") { // HGETALL special case replies with keyed Buffers - if ('HGETALL' === command_obj.command) { + if (reply && 'HGETALL' === command_obj.command) { var obj = {}; for (var i = 0, len = reply.length; i < len; i += 2) { var key = reply[i].toString(), diff --git a/test.js b/test.js index 3faa9ef7b0..0e3ef8e988 100644 --- a/test.js +++ b/test.js @@ -347,6 +347,16 @@ tests.HGETALL = function () { }); }; +tests.HGETALL_NULL = function () { + var name = "HGETALL_NULL"; + client.hgetall('missing', function(err, obj){ + console.log(err); + console.log(obj); + next(name); + }); +}; + + var all_tests = Object.keys(tests), all_start = new Date(), cur_start, test_count = 0;