Commit 5107436c authored by antirez's avatar antirez
Browse files

added overflow check in the double -> long long conversion trick to avoid...

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
parent 128e89dd
...@@ -3513,7 +3513,7 @@ static int rdbSaveDoubleValue(FILE *fp, double val) { ...@@ -3513,7 +3513,7 @@ static int rdbSaveDoubleValue(FILE *fp, double val) {
len = 1; len = 1;
buf[0] = (val < 0) ? 255 : 254; buf[0] = (val < 0) ? 255 : 254;
} else { } 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); ll2string((char*)buf+1,sizeof(buf),(long long)val);
else else
snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val); snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment