aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2011-03-09 13:46:30 +0100
committermilo <milo@r0ot.me>2011-03-17 11:41:50 +0100
commitb05a76870cf95585ca8e29a44644a69af2caf592 (patch)
tree26868d1a5e98f6fb8e32c22b506e117153160b48
parentc090f06c735723ed7464ee64fc35f03f0ebe483b (diff)
downloadlibssh-b05a76870cf95585ca8e29a44644a69af2caf592.tar.gz
libssh-b05a76870cf95585ca8e29a44644a69af2caf592.tar.xz
libssh-b05a76870cf95585ca8e29a44644a69af2caf592.zip
[pki] check for NULL and small cosmetic changes
-rw-r--r--src/pki.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/pki.c b/src/pki.c
index bdb6530..423a06d 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -53,18 +53,18 @@ ssh_key ssh_key_new (void) {
* @param[in] key ssh_key to clean
*/
void ssh_key_clean (ssh_key key){
- if(key==NULL)
- return;
+ if(key == NULL)
+ return;
#ifdef HAVE_LIBGCRYPT
- gcry_sexp_release(key->dsa);
- gcry_sexp_release(key->rsa);
+ if(key->dsa) gcry_sexp_release(key->dsa);
+ if(key->rsa) gcry_sexp_release(key->rsa);
#elif defined HAVE_LIBCRYPTO
- DSA_free(key->dsa);
- RSA_free(key->rsa);
+ if(key->dsa) DSA_free(key->dsa);
+ if(key->rsa) RSA_free(key->rsa);
#endif
- key->flags=SSH_KEY_FLAG_EMPTY;
- key->type=SSH_KEYTYPE_UNKNOWN;
- key->type_c=NULL;
+ key->flags=SSH_KEY_FLAG_EMPTY;
+ key->type=SSH_KEYTYPE_UNKNOWN;
+ key->type_c=NULL;
}
/**
@@ -72,10 +72,10 @@ void ssh_key_clean (ssh_key key){
* @param[in] key ssh_key handle to free
*/
void ssh_key_free (ssh_key key){
- if(key){
- ssh_key_clean(key);
- SAFE_FREE(key);
- }
+ if(key){
+ ssh_key_clean(key);
+ SAFE_FREE(key);
+ }
}
/**
@@ -85,9 +85,10 @@ void ssh_key_free (ssh_key key){
* @returns SSH_KEYTYPE_UNKNOWN if the type is unknown
*/
enum ssh_keytypes_e ssh_key_type(ssh_key key){
- if (key==NULL)
- return SSH_KEYTYPE_UNKNOWN;
- return key->type;
+ if (key == NULL) {
+ return SSH_KEYTYPE_UNKNOWN;
+ }
+ return key->type;
}
/**