diff options
Diffstat (limited to '')
-rw-r--r-- | src/include/common/int.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/include/common/int.h b/src/include/common/int.h index 12a269d..e2617fb 100644 --- a/src/include/common/int.h +++ b/src/include/common/int.h @@ -200,8 +200,12 @@ pg_sub_s64_overflow(int64 a, int64 b, int64 *result) *result = (int64) res; return false; #else + /* + * Note: overflow is also possible when a == 0 and b < 0 (specifically, + * when b == PG_INT64_MIN). + */ if ((a < 0 && b > 0 && a < PG_INT64_MIN + b) || - (a > 0 && b < 0 && a > PG_INT64_MAX + b)) + (a >= 0 && b < 0 && a > PG_INT64_MAX + b)) { *result = 0x5EED; /* to avoid spurious warnings */ return true; |