ldns_key_set_algorithm cannot change state of the key. Check it only
once, return specialized error code if failed.
k = ldns_key_new();
if(!k) return LDNS_STATUS_MEM_ERR;
#ifndef S_SPLINT_S
- k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL);
- if(!k->_key.key) {
- ldns_key_free(k);
- return LDNS_STATUS_ERR;
- }
ldns_key_set_algorithm(k, (ldns_signing_algorithm) alg);
+ k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL);
if (!k->_key.key) {
ldns_key_free(k);
return LDNS_STATUS_ENGINE_KEY_NOT_LOADED;
- }
+ }
#endif /* splint */
*key = k;
return LDNS_STATUS_OK;