Fixed some memory leaks when config could not be loaded/saved.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5294 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-07-13 22:10:52 +00:00
parent fc8dfcf65b
commit 7e226558e4
3 changed files with 25 additions and 5 deletions

View File

@ -310,6 +310,11 @@ bool p3ConfigMgr::backedUpFileSave(const std::string& fname, const std::string&
<< fname_backup << " to " << fname << std::endl
<< sign_fname_backup << " to " << sign_fname << std::endl;
#endif
if (config_buff)
delete[] config_buff;
if (sign_buff)
delete[] sign_buff;
return true;
}
@ -323,6 +328,9 @@ bool p3ConfigMgr::backedUpFileSave(const std::string& fname, const std::string&
#ifdef CONFIG_DEBUG
std::cerr << "p3Config::backedUpFileSave() fopen failed for file: " << fname_backup << std::endl;
#endif
delete[] config_buff;
delete[] sign_buff;
return true;
}
@ -755,7 +763,10 @@ bool p3Config::loadAttempt(const std::string& cfgFname,const std::string& signFn
BinMemInterface *signbio = new BinMemInterface(1000, BIN_FLAGS_READABLE);
if(!signbio->readfromfile(signFname.c_str()))
{
delete signbio;
return false;
}
std::string signatureStored((char *) signbio->memptr(), signbio->memsize());
@ -763,11 +774,11 @@ bool p3Config::loadAttempt(const std::string& cfgFname,const std::string& signFn
std::string strHash(Hash());
AuthSSL::getAuthSSL()->SignData(strHash.c_str(), strHash.length(), signatureRead);
delete signbio;
if(signatureRead != signatureStored)
return false;
delete signbio;
return true;
}
@ -884,6 +895,7 @@ bool p3Config::getHashAttempt(const std::string& loadHash, std::string& hashstr,
setHash("");
delete stream;
return false;
}
@ -1125,6 +1137,7 @@ bool p3Config::backedUpFileSave(const std::string& cfg_fname, const std::string&
{
getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + cfg_fname_backup + "\nIs your disc full or out of quota ?");
fclose(cfg_file);
delete[] buff;
return false ;
}

View File

@ -237,13 +237,18 @@ int BinEncryptedFileInterface::readdata(void* data, int len)
if(-1 == BinFileInterface::readdata(encryptedData, encrypDataLen))
{
delete[] encryptedData;
return -1;
}
if((encrypDataLen > 0) && (encryptedData != NULL))
{
if(!AuthSSL::getAuthSSL()->decrypt((void*&)(this->data), sizeData, encryptedData, encrypDataLen))
{
delete[] encryptedData;
return -1;
}
haveData = true;
delete[] encryptedData;

View File

@ -391,15 +391,17 @@ bool pqiSSLstore::encryptedSendItems(const std::list<RsItem*>& rsItemList)
delete *it;
}
bool result = true;
if(sizeItems == offset)
enc_bio->senddata(data, sizeItems);
else
return false;
result = false;
if(data != NULL)
delete[] data;
return true;
return result;
}
bool pqiSSLstore::getEncryptedItems(std::list<RsItem* >& rsItemList)