From 016e6445a325a114d3564026c46445e1db66b88a Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 17 Jul 2020 00:26:14 +0200 Subject: [PATCH] fixed bug causing dataservice to return a non null group when the DB doesnt contain the requested group, causing rsgxsnetservice to still sync new groups in no mGrpAutoSync mode, causing identities to spread like hell --- libretroshare/src/gxs/rsdataservice.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index bd22a8aa9..5d09fee5d 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -502,6 +502,9 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset RsGxsGrpMetaData* grpMeta ; RsGxsGroupId grpId(tempId) ; + if(grpId.isNull()) // not in the DB! + return nullptr; + if(use_cache) grpMeta = mGrpMetaDataCache.getOrCreateMeta(grpId); else @@ -659,8 +662,10 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset std::string temp; c.getString(mColMsgMeta_MsgId + colOffset, temp); msg_id = RsGxsMessageId(temp); + // without these, a msg is meaningless - ok &= (!group_id.isNull()) && (!msg_id.isNull()); + if(group_id.isNull() || msg_id.isNull()) + return nullptr; RsGxsMsgMetaData* msgMeta = nullptr; @@ -1432,7 +1437,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) RsGxsGrpMetaData *meta = mGrpMetaDataCache.getMeta(mit->first) ; if(meta) - grp[mit->first] = meta; + mit->second = meta; else { #ifdef RS_DATA_SERVICE_DEBUG_CACHE @@ -1446,7 +1451,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp) RsGxsGrpMetaData* meta = locked_getGrpMeta(*c, 0,true); if(meta) - grp[mit->first] = meta; + mit->second = meta; #ifdef RS_DATA_SERVICE_DEBUG_TIME ++resultCount;