diff options
author | David Robillard <d@drobilla.net> | 2018-08-19 13:48:32 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-29 14:48:41 +0200 |
commit | bc2836d41e4de1899e5aa649db849befc9dfa109 (patch) | |
tree | 66f392526befdbebfff8db9c598eb15457b93a6b /chilbert/FixBitVec.hpp | |
parent | 208bd909338a197f2752c7d5336de7d51b8a405b (diff) | |
download | chilbert-bc2836d41e4de1899e5aa649db849befc9dfa109.tar.gz chilbert-bc2836d41e4de1899e5aa649db849befc9dfa109.tar.bz2 chilbert-bc2836d41e4de1899e5aa649db849befc9dfa109.zip |
Fix undefined behaviour
Diffstat (limited to 'chilbert/FixBitVec.hpp')
-rw-r--r-- | chilbert/FixBitVec.hpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/chilbert/FixBitVec.hpp b/chilbert/FixBitVec.hpp index da26d12..001e4c2 100644 --- a/chilbert/FixBitVec.hpp +++ b/chilbert/FixBitVec.hpp @@ -218,7 +218,7 @@ public: /// Right-rotate by `bits` positions CFixBitVec& rotr(const size_t bits) { - if (bits) { + if (bits > 0 && bits < size()) { assert(bits <= bits_per_rack); m_rack &= FBVN1S(size()); m_rack = (m_rack >> bits) | (m_rack << (size() - bits)); @@ -230,7 +230,7 @@ public: /// Left-rotate by `bits` positions CFixBitVec& rotl(const size_t bits) { - if (bits > 0) { + if (bits > 0 && bits < size()) { assert(bits <= bits_per_rack); m_rack &= FBVN1S(size()); m_rack = (m_rack << bits) | (m_rack >> (size() - bits)); |