forked from wolfSSL/wolfssl
Merge pull request #4635 from julek-wolfssl/PrintPubKeyEC-wrong-free
Return early on failed `key` init
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user