From: antirez Date: Wed, 12 May 2010 19:51:48 +0000 (+0200) Subject: added overflow check in the double -> long long conversion trick to avoid integer... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/5107436cdf7c4ec25b7ea5ff4de87dfc10eeb2db added overflow check in the double -> long long conversion trick to avoid integer overflows. I think this was not needed in practical terms, but it is safer --- diff --git a/redis.c b/redis.c index 28f7a8b6..fc921aeb 100644 --- a/redis.c +++ b/redis.c @@ -3513,7 +3513,7 @@ static int rdbSaveDoubleValue(FILE *fp, double val) { len = 1; buf[0] = (val < 0) ? 255 : 254; } else { - if (val == ((long long)val)) + if (val > LLONG_MAX && val < LLONG_MIN && val == ((long long)val)) ll2string((char*)buf+1,sizeof(buf),(long long)val); else snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val);