aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-01-24 21:12:29 -0500
committerJack Lloyd <[email protected]>2019-01-24 21:12:29 -0500
commit4e18bde7f0c9fb15ca0f2337debfae2f1ff7545b (patch)
tree9c88734669a4776d45bdc27cb820fb46f689ba6d /src/lib
parentac52395160eb6a73034105a3e85bc4a82b4bd2d2 (diff)
Fix warning
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/math/bigint/bigint.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/math/bigint/bigint.cpp b/src/lib/math/bigint/bigint.cpp
index d2a2f8ee9..154beb4b7 100644
--- a/src/lib/math/bigint/bigint.cpp
+++ b/src/lib/math/bigint/bigint.cpp
@@ -421,15 +421,18 @@ void BigInt::binary_decode(const uint8_t buf[], size_t length)
const size_t full_words = length / sizeof(word);
const size_t extra_bytes = length % sizeof(word);
- secure_vector<word> reg((round_up(full_words + 1, 8)));
+ secure_vector<word> reg((round_up(full_words + (extra_bytes > 0 ? 1 : 0), 8)));
for(size_t i = 0; i != full_words; ++i)
{
reg[i] = load_be<word>(buf + length - sizeof(word)*(i+1), 0);
}
- for(size_t i = 0; i != length % sizeof(word); ++i)
- reg[full_words] = (reg[full_words] << 8) | buf[i];
+ if(extra_bytes > 0)
+ {
+ for(size_t i = 0; i != extra_bytes; ++i)
+ reg[full_words] = (reg[full_words] << 8) | buf[i];
+ }
m_data.swap(reg);
}