Improve free functions of the keyfiles.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@389 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-04 14:38:39 +00:00
parent 226e48b4b7
commit f7959bd5eb

View File

@@ -664,19 +664,16 @@ void private_key_free(PRIVATE_KEY *prv){
if (prv == NULL) {
return;
}
#ifdef HAVE_LIBGCRYPT
if(prv->dsa_priv)
gcry_sexp_release(prv->dsa_priv);
if(prv->rsa_priv)
gcry_sexp_release(prv->rsa_priv);
#elif defined HAVE_LIBCRYPTO
if(prv->dsa_priv)
DSA_free(prv->dsa_priv);
if(prv->rsa_priv)
RSA_free(prv->rsa_priv);
#endif
memset(prv, 0, sizeof(PRIVATE_KEY));
free(prv);
SAFE_FREE(prv);
}
/** \brief Retrieve a public key from a file
@@ -826,11 +823,15 @@ static char *lowercase(const char* str) {
* \internal
*/
static void tokens_free(char **tokens) {
free(tokens[0]);
if (tokens == NULL) {
return;
}
SAFE_FREE(tokens[0]);
/* It's not needed to free other pointers because tokens generated by
* space_tokenize fit all in one malloc
*/
free(tokens);
SAFE_FREE(tokens);
}
/** \brief returns one line of known host file
* will return a token array containing (host|ip) keytype key