mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
fixed some leaking memory issues in loadList() methods, and also increased consistency by not returning non empty list with deleted items inside
This commit is contained in:
parent
48750cdb51
commit
8a41554754
@ -1199,6 +1199,7 @@ bool p3ChatService::loadList(std::list<RsItem*>& load)
|
|||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,6 +1052,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
|
|||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
|
|
||||||
/* assemble a list of dirs to clean (union of cache dirs) */
|
/* assemble a list of dirs to clean (union of cache dirs) */
|
||||||
std::list<std::string> cacheDirs;
|
std::list<std::string> cacheDirs;
|
||||||
|
@ -279,6 +279,11 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
/* error */
|
/* error */
|
||||||
std::cerr << "p3BitDht::loadList() Error only expecting 1 item";
|
std::cerr << "p3BitDht::loadList() Error only expecting 1 item";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
for(std::list<RsItem*>::iterator it=load.begin();it!=load.end();++it)
|
||||||
|
delete *it ;
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RsItem *item = load.front();
|
RsItem *item = load.front();
|
||||||
@ -290,6 +295,7 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
/* error */
|
/* error */
|
||||||
std::cerr << "p3BitDht::loadList() Error expecting item = config";
|
std::cerr << "p3BitDht::loadList() Error expecting item = config";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
delete item ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +399,7 @@ bool p3BitDht::loadList(std::list<RsItem *>& load)
|
|||||||
setRelayMode(mode);
|
setRelayMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2224,6 +2224,7 @@ bool ftController::loadList(std::list<RsItem *>& load)
|
|||||||
/* cleanup */
|
/* cleanup */
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,8 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
|
|||||||
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
||||||
setWatchPeriod(t);
|
setWatchPeriod(t);
|
||||||
}
|
}
|
||||||
|
delete *it ;
|
||||||
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
||||||
@ -348,10 +350,13 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
|
|||||||
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
|
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
|
||||||
|
|
||||||
dirList.push_back(info) ;
|
dirList.push_back(info) ;
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set directories */
|
/* set directories */
|
||||||
setSharedDirectories(dirList);
|
setSharedDirectories(dirList);
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,6 +484,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
|
|||||||
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2095,6 +2095,7 @@ bool p3GRouter::loadList(std::list<RsItem*>& items)
|
|||||||
#ifdef GROUTER_DEBUG
|
#ifdef GROUTER_DEBUG
|
||||||
debugDump();
|
debugDump();
|
||||||
#endif
|
#endif
|
||||||
|
items.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
bool p3GRouter::saveList(bool& cleanup,std::list<RsItem*>& items)
|
bool p3GRouter::saveList(bool& cleanup,std::list<RsItem*>& items)
|
||||||
|
@ -310,6 +310,18 @@ RsGxsNetService::~RsGxsNetService()
|
|||||||
it->second.clear() ;
|
it->second.clear() ;
|
||||||
}
|
}
|
||||||
mTransactions.clear() ;
|
mTransactions.clear() ;
|
||||||
|
|
||||||
|
delete mGrpServerUpdateItem ;
|
||||||
|
|
||||||
|
for(ClientGrpMap::iterator it = mClientGrpUpdateMap.begin();it!=mClientGrpUpdateMap.end();++it)
|
||||||
|
delete it->second ;
|
||||||
|
|
||||||
|
mClientGrpUpdateMap.clear() ;
|
||||||
|
|
||||||
|
for(std::map<RsGxsGroupId, RsGxsServerMsgUpdateItem*>::iterator it(mServerMsgUpdateMap.begin());it!=mServerMsgUpdateMap.end();)
|
||||||
|
delete it->second ;
|
||||||
|
|
||||||
|
mServerMsgUpdateMap.clear() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1310,9 +1322,7 @@ public:
|
|||||||
else if((gsui = dynamic_cast<RsGxsServerGrpUpdateItem*>(item)) != NULL)
|
else if((gsui = dynamic_cast<RsGxsServerGrpUpdateItem*>(item)) != NULL)
|
||||||
{
|
{
|
||||||
if(mServerGrpUpdateItem == NULL)
|
if(mServerGrpUpdateItem == NULL)
|
||||||
{
|
|
||||||
mServerGrpUpdateItem = gsui;
|
mServerGrpUpdateItem = gsui;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Error! More than one server group update item exists!" << std::endl;
|
std::cerr << "Error! More than one server group update item exists!" << std::endl;
|
||||||
@ -1320,7 +1330,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
std::cerr << "Type not expected!" << std::endl;
|
std::cerr << "Type not expected!" << std::endl;
|
||||||
|
delete item ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1336,6 +1349,8 @@ bool RsGxsNetService::loadList(std::list<RsItem *> &load)
|
|||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mNxsMutex) ;
|
RS_STACK_MUTEX(mNxsMutex) ;
|
||||||
|
|
||||||
|
// The delete is done in StoreHere, if necessary
|
||||||
|
|
||||||
std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mGrpServerUpdateItem));
|
std::for_each(load.begin(), load.end(), StoreHere(mClientGrpUpdateMap, mClientMsgUpdateMap, mServerMsgUpdateMap, mGrpServerUpdateItem));
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ class RsCacheService: public CacheSource, public CacheStore, public p3Config
|
|||||||
// Functions from p3config
|
// Functions from p3config
|
||||||
//
|
//
|
||||||
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
||||||
virtual bool saveList(bool&, std::list<RsItem*>&) { return false ;}
|
virtual bool saveList(bool&, std::list<RsItem*>&) =0;
|
||||||
virtual bool loadList(std::list<RsItem*>&) { return false ;}
|
virtual bool loadList(std::list<RsItem*>&) =0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t _tick_delay_in_seconds ;
|
uint32_t _tick_delay_in_seconds ;
|
||||||
|
@ -17,8 +17,8 @@ class RsPQIService: public p3Service, public p3Config
|
|||||||
// Functions from p3config
|
// Functions from p3config
|
||||||
//
|
//
|
||||||
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
virtual RsSerialiser *setupSerialiser() { return NULL ; }
|
||||||
virtual bool saveList(bool&, std::list<RsItem*>&) { return false ;}
|
virtual bool saveList(bool&, std::list<RsItem*>&) =0 ;
|
||||||
virtual bool loadList(std::list<RsItem*>&) { return false ;}
|
virtual bool loadList(std::list<RsItem*>&) =0 ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t _tick_delay_in_seconds ;
|
uint32_t _tick_delay_in_seconds ;
|
||||||
|
@ -715,6 +715,7 @@ bool AuthGPG::loadList(std::list<RsItem*>& load)
|
|||||||
}
|
}
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1705,6 +1705,7 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
|
|||||||
}
|
}
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,8 @@ bool p3HistoryMgr::loadList(std::list<RsItem*>& load)
|
|||||||
RsHistoryMsgItem *msgItem;
|
RsHistoryMsgItem *msgItem;
|
||||||
std::list<RsItem*>::iterator it;
|
std::list<RsItem*>::iterator it;
|
||||||
|
|
||||||
for (it = load.begin(); it != load.end(); ++it) {
|
for (it = load.begin(); it != load.end(); ++it)
|
||||||
|
{
|
||||||
if (NULL != (msgItem = dynamic_cast<RsHistoryMsgItem*>(*it))) {
|
if (NULL != (msgItem = dynamic_cast<RsHistoryMsgItem*>(*it))) {
|
||||||
|
|
||||||
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(msgItem->chatPeerId);
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(msgItem->chatPeerId);
|
||||||
@ -381,6 +382,7 @@ bool p3HistoryMgr::loadList(std::list<RsItem*>& load)
|
|||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2360,6 +2360,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
|||||||
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,12 +1180,13 @@ bool p3ServiceControl::loadList(std::list<RsItem *>& loadList)
|
|||||||
{
|
{
|
||||||
RsServicePermissionItem *item = dynamic_cast<RsServicePermissionItem*>(*it) ;
|
RsServicePermissionItem *item = dynamic_cast<RsServicePermissionItem*>(*it) ;
|
||||||
|
|
||||||
if(item == NULL)
|
if(item != NULL)
|
||||||
continue ;
|
|
||||||
|
|
||||||
mServicePermissionMap[item->mServiceId] = *item ;
|
mServicePermissionMap[item->mServiceId] = *item ;
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadList.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,6 +885,7 @@ bool p3BanList::loadList(std::list<RsItem*>& load)
|
|||||||
delete *it ;
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,6 +793,7 @@ bool p3GxsReputation::loadList(std::list<RsItem *>& loadList)
|
|||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadList.clear() ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +275,7 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
|
|||||||
RsGxsIdLocalInfoItem *lii;
|
RsGxsIdLocalInfoItem *lii;
|
||||||
|
|
||||||
for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it)
|
for(std::list<RsItem*>::const_iterator it = items.begin();it!=items.end();++it)
|
||||||
|
{
|
||||||
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
|
if( (lii = dynamic_cast<RsGxsIdLocalInfoItem*>(*it)) != NULL)
|
||||||
{
|
{
|
||||||
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
|
for(std::map<RsGxsId,time_t>::const_iterator it2 = lii->mTimeStamps.begin();it2!=lii->mTimeStamps.end();++it2)
|
||||||
@ -283,6 +284,10 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
|
|||||||
mContacts = lii->mContacts ;
|
mContacts = lii->mContacts ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
|
}
|
||||||
|
|
||||||
|
items.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,6 +602,7 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
|
|||||||
RsConfigKeyValueSet *vitem = NULL ;
|
RsConfigKeyValueSet *vitem = NULL ;
|
||||||
|
|
||||||
if(NULL != (vitem = dynamic_cast<RsConfigKeyValueSet*>(*it)))
|
if(NULL != (vitem = dynamic_cast<RsConfigKeyValueSet*>(*it)))
|
||||||
|
{
|
||||||
for(std::list<RsTlvKeyValue>::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
for(std::list<RsTlvKeyValue>::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||||
{
|
{
|
||||||
if(kit->key == "DISTANT_MESSAGES_ENABLED")
|
if(kit->key == "DISTANT_MESSAGES_ENABLED")
|
||||||
@ -631,7 +632,11 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
|
continue ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
load.clear() ;
|
||||||
|
|
||||||
// sort items into lists
|
// sort items into lists
|
||||||
std::list<RsMsgItem*>::iterator msgIt;
|
std::list<RsMsgItem*>::iterator msgIt;
|
||||||
|
@ -309,27 +309,21 @@ bool p3StatusService::saveList(bool& cleanup, std::list<RsItem*>& ilist){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3StatusService::loadList(std::list<RsItem*>& load){
|
bool p3StatusService::loadList(std::list<RsItem*>& load)
|
||||||
|
{
|
||||||
// load your status from last rs session
|
// load your status from last rs session
|
||||||
StatusInfo own_info;
|
StatusInfo own_info;
|
||||||
std::list<RsItem*>::const_iterator it = load.begin();
|
|
||||||
|
|
||||||
if(it == load.end()){
|
|
||||||
std::cerr << "p3StatusService::loadList(): Failed to load " << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(; it != load.end(); ++it){
|
for(std::list<RsItem*>::const_iterator it = load.begin() ; it != load.end(); ++it)
|
||||||
|
{
|
||||||
RsStatusItem* own_status = dynamic_cast<RsStatusItem* >(*it);
|
RsStatusItem* own_status = dynamic_cast<RsStatusItem* >(*it);
|
||||||
|
|
||||||
|
if(own_status != NULL)
|
||||||
if(own_status != NULL){
|
{
|
||||||
|
|
||||||
own_info.id = mServiceCtrl->getOwnId();
|
own_info.id = mServiceCtrl->getOwnId();
|
||||||
own_info.status = own_status->status;
|
own_info.status = own_status->status;
|
||||||
own_info.time_stamp = own_status->sendTime;
|
own_info.time_stamp = own_status->sendTime;
|
||||||
delete own_status;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mStatusMtx);
|
RsStackMutex stack(mStatusMtx);
|
||||||
@ -337,13 +331,11 @@ bool p3StatusService::loadList(std::list<RsItem*>& load){
|
|||||||
mStatusInfoMap.insert(pr);
|
mStatusInfoMap.insert(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
std::cerr << "p3StatusService::loadList " << "Failed to load list "
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete *it ;
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,6 +728,7 @@ bool p3turtle::loadList(std::list<RsItem*>& load)
|
|||||||
|
|
||||||
delete vitem ;
|
delete vitem ;
|
||||||
}
|
}
|
||||||
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
int p3turtle::getMaxTRForwardRate() const
|
int p3turtle::getMaxTRForwardRate() const
|
||||||
|
@ -784,6 +784,7 @@ bool p3VOIP::loadList(std::list<RsItem*>& load)
|
|||||||
delete vitem ;
|
delete vitem ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user