From e6d3ee978b33e05403a44d11e670e7ca595c5fd6 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sun, 5 Sep 2021 18:11:58 +0200 Subject: [PATCH] Fixes crash after: (EE) asked to create an invalidated profile that already exists createInvalidatedProfile returned with iterator.end() in some cases. updateInternalData dereferenced the result without checking it first. It overindexed an array, read some memory trash, then wrote it into an another array. --- retroshare-gui/src/gui/common/FriendListModel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 9d2bfa50b..1b83485bc 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -1052,7 +1052,12 @@ std::map::const_iterator RsFriendListModel::createInvalidatedP if(rsPeers->getGPGDetails(pgp_id,hprof.profile_info)) { - std::cerr << "(EE) asked to create an invalidated profile that already exists!" << std::endl; + std::cerr << "(EE) asked to create an invalidated profile that already exists: " << pgp_id << std::endl; + + pgp_indices[pgp_id] = mProfiles.size(); + mProfiles.push_back(hprof); + it2 = pgp_indices.find(pgp_id); + return it2; }