Early returns when signature/key type are incompatible bypass cleanup
of `tmp_keymgmt` allocated via `evp_keymgmt_fetch_from_prov()`. Use goto
to ensure `EVP_KEYMGMT_free()` is called on all error paths.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Tue Jan 20 19:01:17 2026
(Merged from https://github.com/openssl/openssl/pull/29651)
break;
if (*keytypes == NULL) {
ERR_raise(ERR_LIB_EVP, EVP_R_SIGNATURE_TYPE_AND_KEY_TYPE_INCOMPATIBLE);
- return -2;
+ ret = -2;
+ goto end;
}
} else {
/*
/* If none of the fallbacks helped, we're lost */
if (!ok) {
ERR_raise(ERR_LIB_EVP, EVP_R_SIGNATURE_TYPE_AND_KEY_TYPE_INCOMPATIBLE);
- return -2;
+ ret = -2;
+ goto end;
}
}
if (!EVP_SIGNATURE_up_ref(signature))
- return 0;
+ goto err;
} else {
/* Without a pre-fetched signature, it must be figured out somehow */
ERR_set_mark();