diff --git a/index.js b/index.js index d5efbbc74d..54033ea58e 100644 --- a/index.js +++ b/index.js @@ -632,7 +632,7 @@ RedisClient.prototype.send_command = function (command, args, callback) { // and converts to: // client.command(arg1, arg2, arg3, arg4, cb); // which is convenient for some things like sadd - if (Array.isArray(args[args.length - 1])) { + if (args.length > 0 && Array.isArray(args[args.length - 1])) { args = args.slice(0, -1).concat(args[args.length - 1]); } diff --git a/test.js b/test.js index a02b36b1fc..a146a32f3d 100644 --- a/test.js +++ b/test.js @@ -158,7 +158,7 @@ tests.MULTI_3 = function () { // make sure empty mb reply works assert.strictEqual(true, is_empty_array(reply), name); }); - + // test nested multi-bulk replies with empty mb elements. client.multi([ ["smembers", "some set"],