fixed bug due to not using realloc correctly (thanks valgrind)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6385 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-05-30 19:43:05 +00:00
parent 0d3d8ed2bd
commit b4f26dcf8f
2 changed files with 7 additions and 10 deletions

View file

@ -820,11 +820,14 @@ bool PGPHandler::importGPGKeyPair(const std::string& filename,PGPIdType& importe
void PGPHandler::addNewKeyToOPSKeyring(ops_keyring_t *kr,const ops_keydata_t& key)
{
kr->keys = (ops_keydata_t*)realloc(kr->keys,(kr->nkeys+1)*sizeof(ops_keydata_t)) ;
if(kr->nkeys >= kr->nkeys_allocated)
{
kr->keys = (ops_keydata_t *)realloc(kr->keys,(kr->nkeys+1)*sizeof(ops_keydata_t)) ;
kr->nkeys_allocated = kr->nkeys+1;
}
memset(&kr->keys[kr->nkeys],0,sizeof(ops_keydata_t)) ;
ops_keydata_copy(&kr->keys[kr->nkeys],&key) ;
kr->nkeys++ ;
kr->nkeys_allocated = kr->nkeys ;
}
bool PGPHandler::LoadCertificateFromString(const std::string& pgp_cert,PGPIdType& id,std::string& error_string)