From faca4a8dc95d265a14d75e634363f4b27b496fb6 Mon Sep 17 00:00:00 2001 From: Matt Ranney Date: Wed, 16 Nov 2011 12:10:19 -1000 Subject: [PATCH] Bounds checking on Array expansion magic. --- index.js | 2 +- test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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"],