From 3d1362757be1c8ac73f2f7937ac0dcd696ca6f46 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Wed, 28 Nov 2018 15:37:25 +0900 Subject: [PATCH] Prevent potential undefined behavior by shifting by a wrapped uint. Found by clang static analyzer. --- libgnucash/engine/gnc-int128.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libgnucash/engine/gnc-int128.cpp b/libgnucash/engine/gnc-int128.cpp index 3da9a9fade..d4c25bea17 100644 --- a/libgnucash/engine/gnc-int128.cpp +++ b/libgnucash/engine/gnc-int128.cpp @@ -374,6 +374,8 @@ GncInt128& GncInt128::operator<<= (unsigned int i) noexcept { auto flags = get_flags(m_hi); + if (i == 0) + return *this; if (i > maxbits) { flags &= 0xfe;