X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/794e6ce14ff85f00b0d3e86365e9cc45a90d3bcf..f892797e1b459ad568df32d891b368302c40b3c9:/src/t_string.c diff --git a/src/t_string.c b/src/t_string.c index 2bd1646e..d6143ed2 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -344,11 +344,12 @@ void incrDecrCommand(redisClient *c, long long incr) { if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return; oldvalue = value; - value += incr; - if ((incr < 0 && value > oldvalue) || (incr > 0 && value < oldvalue)) { + if ((incr < 0 && oldvalue < 0 && incr < (LLONG_MIN-oldvalue)) || + (incr > 0 && oldvalue > 0 && incr > (LLONG_MAX-oldvalue))) { addReplyError(c,"increment or decrement would overflow"); return; } + value += incr; new = createStringObjectFromLongLong(value); if (o) dbOverwrite(c->db,c->argv[1],new);