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:
parent
6d4317a1e4
commit
1035d74025
@ -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':
|
||||
|
Loading…
x
Reference in New Issue
Block a user