Skip to content

Commit

Permalink
Fix ODR violation in ThemisPP (#576)
Browse files Browse the repository at this point in the history
All functions defined in header files should be marked "inline"
so that the compiler does proper deduplication and does not violate
"one definition rule" (ODR). Otherwise (you guessed it, right?)
undefined behavior happens.

Thanks goes go "clang-analyzer" whose warnings we diligently ignore.
We've been burnt by this in the past and I never learn because C++ is
such a monster that I easily forget something about it all the time.
  • Loading branch information
ilammy authored Jan 27, 2020
1 parent f78d72c commit 077561d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wrappers/themis/themispp/secure_keygen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ inline bool is_public_key(const std::vector<uint8_t>& key)
* If the vector does not have enough space for a good key then
* it will be resized. Otherwise no reallocations are performed.
*/
void gen_sym_key(std::vector<uint8_t>& key)
inline void gen_sym_key(std::vector<uint8_t>& key)
{
if (key.empty()) {
size_t key_length = 0;
Expand All @@ -165,7 +165,7 @@ void gen_sym_key(std::vector<uint8_t>& key)
*
* @returns a newly allocated key of default size.
*/
std::vector<uint8_t> gen_sym_key()
inline std::vector<uint8_t> gen_sym_key()
{
std::vector<uint8_t> key;
gen_sym_key(key);
Expand Down

0 comments on commit 077561d

Please sign in to comment.