X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/28d1ee2cda01bccdd2424f8fdbb4a924de37eaa3..4b1f6ad3e7a5c7c28618e43e7539c9a937bf8521:/src/db.c?ds=sidebyside diff --git a/src/db.c b/src/db.c index fff63f48..5f07e2b6 100644 --- a/src/db.c +++ b/src/db.c @@ -228,7 +228,11 @@ void existsCommand(redisClient *c) { } void selectCommand(redisClient *c) { - int id = atoi(c->argv[1]->ptr); + long id; + + if (getLongFromObjectOrReply(c, c->argv[1], &id, + "invalid DB index") != REDIS_OK) + return; if (server.cluster_enabled && id != 0) { addReplyError(c,"SELECT is not allowed in cluster mode"); @@ -261,7 +265,7 @@ void keysCommand(redisClient *c) { unsigned long numkeys = 0; void *replylen = addDeferredMultiBulkLength(c); - di = dictGetIterator(c->db->dict); + di = dictGetSafeIterator(c->db->dict); allkeys = (pattern[0] == '*' && pattern[1] == '\0'); while((de = dictNext(di)) != NULL) { sds key = dictGetKey(de);