1
1

[pki] check for NULL and small cosmetic changes

Этот коммит содержится в:
milo 2011-03-09 13:46:30 +01:00
родитель 2694853979
Коммит c5db7674ec

Просмотреть файл

@ -53,18 +53,18 @@ ssh_key ssh_key_new (void) {
* @param[in] key ssh_key to clean * @param[in] key ssh_key to clean
*/ */
void ssh_key_clean (ssh_key key){ void ssh_key_clean (ssh_key key){
if(key==NULL) if(key == NULL)
return; return;
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT
gcry_sexp_release(key->dsa); if(key->dsa) gcry_sexp_release(key->dsa);
gcry_sexp_release(key->rsa); if(key->rsa) gcry_sexp_release(key->rsa);
#elif defined HAVE_LIBCRYPTO #elif defined HAVE_LIBCRYPTO
DSA_free(key->dsa); if(key->dsa) DSA_free(key->dsa);
RSA_free(key->rsa); if(key->rsa) RSA_free(key->rsa);
#endif #endif
key->flags=SSH_KEY_FLAG_EMPTY; key->flags=SSH_KEY_FLAG_EMPTY;
key->type=SSH_KEYTYPE_UNKNOWN; key->type=SSH_KEYTYPE_UNKNOWN;
key->type_c=NULL; key->type_c=NULL;
} }
/** /**
@ -72,10 +72,10 @@ void ssh_key_clean (ssh_key key){
* @param[in] key ssh_key handle to free * @param[in] key ssh_key handle to free
*/ */
void ssh_key_free (ssh_key key){ void ssh_key_free (ssh_key key){
if(key){ if(key){
ssh_key_clean(key); ssh_key_clean(key);
SAFE_FREE(key); SAFE_FREE(key);
} }
} }
/** /**
@ -85,9 +85,10 @@ void ssh_key_free (ssh_key key){
* @returns SSH_KEYTYPE_UNKNOWN if the type is unknown * @returns SSH_KEYTYPE_UNKNOWN if the type is unknown
*/ */
enum ssh_keytypes_e ssh_key_type(ssh_key key){ enum ssh_keytypes_e ssh_key_type(ssh_key key){
if (key==NULL) if (key == NULL) {
return SSH_KEYTYPE_UNKNOWN; return SSH_KEYTYPE_UNKNOWN;
return key->type; }
return key->type;
} }
/** /**