fixed missing error handling, causing unhandled exception

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7003 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-01-09 20:20:46 +00:00
parent 3a567b2d6f
commit 99b9b53c62

View File

@ -122,6 +122,7 @@ RsCertificate::RsCertificate(const std::string& str)
dns_name(""),only_pgp(true) dns_name(""),only_pgp(true)
{ {
uint32_t err_code ; uint32_t err_code ;
binary_pgp_key = NULL ;
if(!initFromString(str,err_code) && !initFromString_oldFormat(str,err_code)) if(!initFromString(str,err_code) && !initFromString_oldFormat(str,err_code))
throw err_code ; throw err_code ;
@ -176,6 +177,8 @@ void RsCertificate::scan_ip(const std::string& ip_string, unsigned short port,un
} }
bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code) bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
{
try
{ {
std::string str ; std::string str ;
err_code = CERTIFICATE_PARSING_ERROR_NO_ERROR ; err_code = CERTIFICATE_PARSING_ERROR_NO_ERROR ;
@ -313,6 +316,15 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
delete[] bf ; delete[] bf ;
return true ; return true ;
} }
catch(std::exception& e)
{
if(binary_pgp_key != NULL)
delete[] binary_pgp_key ;
err_code = CERTIFICATE_PARSING_ERROR_SIZE_ERROR ;
return false ;
}
}
std::string RsCertificate::sslid_string() const std::string RsCertificate::sslid_string() const
{ {