Fix the overflow test. It is possible for the result of an

overflowing shift to be larger than the original value, e.g.

         (uint64_t)1 << 53 = 0x20000000000000
 ((uint64_t)1 << 53) << 10 = 0x8000000000000000
This commit is contained in:
Dag-Erling Smørgrav 2010-08-15 14:50:03 +00:00
parent 6d4317a1e4
commit 1035d74025
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211337

View File

@ -67,7 +67,7 @@ expand_number(const char *buf, uint64_t *num)
}
#define SHIFT(n, b) \
do { if ((n << b) < n) goto overflow; n <<= b; } while (0)
do { if (((n << b) >> b) != n) goto overflow; n <<= b; } while (0)
switch (tolower((unsigned char)*endptr)) {
case 'e':