Return early on failed key init

This commit is contained in:
Juliusz Sosinowicz
2021-12-07 18:11:19 +01:00
parent 96daf2bede
commit 223f25149b

View File

@ -8182,6 +8182,13 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
return WOLFSSL_FAILURE;
}
if (wc_ecc_init(&key) != 0) {
/* Return early so we don't have to remember if init succeeded
* or not. */
mp_free(&a);
return WOLFSSL_FAILURE;
}
if (indent < 0) {
indent = 0;
}
@ -8189,8 +8196,6 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
indent = EVP_PKEY_PRINT_INDENT_MAX;
}
res = wc_ecc_init(&key) == 0;
if (res == WOLFSSL_SUCCESS) {
res = wc_EccPublicKeyDecode(pkey, &inOutIdx, &key, pkeySz) == 0;
}