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

This commit is contained in:
antirez 2010-05-12 21:51:48 +02:00
parent 128e89dde2
commit 5107436cdf
1 changed files with 1 additions and 1 deletions

View File

@ -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);