Skip to content

Commit 2739d8e

Browse files
committed
add if (!value.hasOwnProperty(vKey)) continue; that occurred bugs!
1 parent 5f58e12 commit 2739d8e

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
node_modules
2+
.idea
3+
*.swp
4+
*.log
5+

lib/memcached.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ var curry = Utils.curry;
3131
function Client (args, options) {
3232
var servers = []
3333
, weights = {}
34-
, regular = 'localhost:11211'
35-
, key;
34+
, regular = 'localhost:11211';
3635

3736
// Parse down the connection arguments
3837
switch (Object.prototype.toString.call(args)) {
@@ -112,8 +111,7 @@ Client.config = {
112111
nMemcached.prototype.__proto__ = require('events').EventEmitter.prototype;
113112

114113
var memcached = nMemcached.prototype
115-
, privates = {}
116-
, undefined;
114+
, privates = {};
117115

118116
// Creates or generates a new connection for the give server, the callback
119117
// will receive the connection if the operation was successful
@@ -319,7 +317,7 @@ Client.config = {
319317
var S = {
320318
serverAddress: server,
321319
tokens: server.split(':').reverse()
322-
}
320+
};
323321
var message = error || 'Unable to connect to server';
324322
memcached.connectionIssue(message, S);
325323
return query.callback && memcached.makeCallback(query.callback,new Error(message));
@@ -706,8 +704,7 @@ Client.config = {
706704
, dataSet
707705
, resultSet
708706
, metaData
709-
, err = []
710-
, tmp;
707+
, err = [];
711708

712709
while(S.bufferArray.length && privates.allCommands.test(S.bufferArray[0])) {
713710
token = S.bufferArray.shift();

lib/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ exports.validateArg = function validateArg (args, config) {
3131
}
3232
if (!err && key === 'key') {
3333
for (var vKey in value) {
34+
if (!value.hasOwnProperty(vKey)) continue;
3435
var vValue = value[vKey];
3536
var result = validateKeySize(config, vKey, vValue);
3637
if (result.err) {
38+
if (result.err === 'function') {
39+
continue;
40+
}
3741
err = result.err;
3842
} else {
3943
args.command = args.command.replace(vValue, result['value']);
@@ -87,6 +91,10 @@ exports.validateArg = function validateArg (args, config) {
8791
};
8892

8993
var validateKeySize = function validateKeySize(config, key, value) {
94+
if (typeof value === 'function') {
95+
return { err: 'function' };
96+
}
97+
9098
if (value.length > config.maxKeySize) {
9199
if (config.keyCompression){
92100
return { err: false, value: createHash('md5').update(value).digest('hex') };
@@ -111,6 +119,7 @@ exports.fuse = function fuse (target, handlers) {
111119
// merges a object's proppertys / values with a other object
112120
exports.merge = function merge (target, obj) {
113121
for (var i in obj) {
122+
if (!obj.hasOwnProperty(i)) continue;
114123
target[i] = obj[i];
115124
}
116125

0 commit comments

Comments
 (0)