From 8ad10978b96837eb7949f32ef433c5b37c2aa458 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 7 Jan 2025 20:51:32 +0100 Subject: [PATCH] fix unconditional access --- solanaceae/tox_contacts/tox_contact_model2.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/solanaceae/tox_contacts/tox_contact_model2.cpp b/solanaceae/tox_contacts/tox_contact_model2.cpp index 557cb72..d727c3d 100644 --- a/solanaceae/tox_contacts/tox_contact_model2.cpp +++ b/solanaceae/tox_contacts/tox_contact_model2.cpp @@ -196,7 +196,17 @@ Contact3Handle ToxContactModel2::getContactFriend(uint32_t friend_number) { } if (!_cr.all_of(c)) { - _cr.emplace_or_replace(c, std::min(_cr.get(c).ts, ts)); + if (_cr.all_of(c)) { + _cr.emplace_or_replace(c, + std::min( + _cr.get(c).ts, + ts + ) + ); + } else { + // TODO: did we? + _cr.emplace_or_replace(c, ts); + } } std::cout << "TCM2: created friend contact " << friend_number << "\n";