diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 4d70a3c14..4490a0f1f 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -468,6 +468,7 @@ static ActorOwn<> get_full_config(DcOption option, Promiseget_server_time_difference(); } void add_auth_key_listener(unique_ptr listener) final { + CHECK(listener != nullptr); if (listener->notify()) { auth_key_listeners_.push_back(std::move(listener)); } @@ -493,7 +494,10 @@ static ActorOwn<> get_full_config(DcOption option, Promise> auth_key_listeners_; void notify() { - td::remove_if(auth_key_listeners_, [&](auto &listener) { return !listener->notify(); }); + td::remove_if(auth_key_listeners_, [&](auto &listener) { + CHECK(listener != nullptr); + return !listener->notify(); + }); } string auth_key_key() const { diff --git a/td/telegram/net/AuthDataShared.cpp b/td/telegram/net/AuthDataShared.cpp index 59e99c5d2..cab5658b4 100644 --- a/td/telegram/net/AuthDataShared.cpp +++ b/td/telegram/net/AuthDataShared.cpp @@ -64,6 +64,7 @@ class AuthDataSharedImpl final : public AuthDataShared { } void add_auth_key_listener(unique_ptr listener) final { + CHECK(listener != nullptr); if (listener->notify()) { auto lock = rw_mutex_.lock_write(); auth_key_listeners_.push_back(std::move(listener)); @@ -98,9 +99,11 @@ class AuthDataSharedImpl final : public AuthDataShared { } void notify() { - auto lock = rw_mutex_.lock_read(); - - td::remove_if(auth_key_listeners_, [&](auto &listener) { return !listener->notify(); }); + auto lock = rw_mutex_.lock_write(); + td::remove_if(auth_key_listeners_, [&](auto &listener) { + CHECK(listener != nullptr); + return !listener->notify(); + }); } void log_auth_key(const mtproto::AuthKey &auth_key) {