diff --git a/passphrase_cache.cc b/passphrase_cache.cc index e6413f9..d11a2f1 100644 --- a/passphrase_cache.cc +++ b/passphrase_cache.cc @@ -48,6 +48,7 @@ namespace pEp { const char *PassphraseCache::add_stored(const std::string& passphrase) { + std::lock_guard lock(_shared_mtx); _stored = passphrase; return _stored.c_str(); } diff --git a/passphrase_cache.hh b/passphrase_cache.hh index 99ab574..3a82655 100644 --- a/passphrase_cache.hh +++ b/passphrase_cache.hh @@ -26,6 +26,7 @@ namespace pEp { cache _cache; std::string _stored; std::mutex _mtx; + std::mutex _shared_mtx; size_t _max_size; duration _timeout;