From 8df29d169cd310fda0ac7c20a5cbd11ac12d4b0f Mon Sep 17 00:00:00 2001 From: practicalswift Date: Tue, 27 Mar 2018 19:15:26 +0200 Subject: [PATCH] The overflow check mul_overflows_s64(int64_t, int64_t) overflows and triggers UB :-) Remove it The overflow check `mul_overflows_s64(int64_t, int64_t)` overflows. Since this is an signed integer overflow this triggers UB, which in turn means that we cannot trust the check. Luckily mul_overflows_s64(int64_t, int64_t) is unused. Removing it. --- common/overflows.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/common/overflows.h b/common/overflows.h index c44274868..b649532ef 100644 --- a/common/overflows.h +++ b/common/overflows.h @@ -12,16 +12,6 @@ static inline bool add_overflows_u64(uint64_t a, uint64_t b) return (a + b) < a; } -static inline bool mul_overflows_s64(int64_t a, int64_t b) -{ - int64_t ret; - - if (a == 0) - return false; - ret = a * b; - return (ret / a != b); -} - static inline bool mul_overflows_u64(uint64_t a, uint64_t b) { uint64_t ret;