From 9bfaf7e434b1f0d406a46a3b1071fcc3c4e38ad5 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Wed, 25 Sep 2024 09:32:40 +0200 Subject: [PATCH] protect find_msb from passing 0 --- .../include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp index 938814bca6..ccc79be072 100644 --- a/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp +++ b/crypto3/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/misc.hpp @@ -148,6 +148,8 @@ namespace boost { return i * cpp_int_modular_backend::limb_bits + boost::multiprecision::detail::find_msb(a.limbs()[i]); } + if (a.limbs()[0] == 0) // TODO here should assert/throw + return 1024; // Some big number to indicate that there is no bit 1 return boost::multiprecision::detail::find_msb(a.limbs()[0]); }