diff options
Diffstat (limited to 'src/bitops.c')
-rw-r--r-- | src/bitops.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bitops.c b/src/bitops.c index f1c563a41..841f6d644 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -328,8 +328,9 @@ int checkSignedBitfieldOverflow(int64_t value, int64_t incr, uint64_t bits, int /* Note that maxincr and minincr could overflow, but we use the values * only after checking 'value' range, so when we use it no overflow - * happens. */ - int64_t maxincr = max-value; + * happens. 'uint64_t' cast is there just to prevent undefined behavior on + * overflow */ + int64_t maxincr = (uint64_t)max-value; int64_t minincr = min-value; if (value > max || (bits != 64 && incr > maxincr) || (value >= 0 && incr > 0 && incr > maxincr)) |