diff --git a/client/src/cmdhfvas.c b/client/src/cmdhfvas.c index 839474cc5..d4c254508 100644 --- a/client/src/cmdhfvas.c +++ b/client/src/cmdhfvas.c @@ -187,18 +187,19 @@ static int LoadReaderPrivateKey(uint8_t *buf, size_t bufLen, mbedtls_ecp_keypair return PM3_EINVARG; } - tlvdb_free(derRoot); - if (mbedtls_ecp_point_read_binary(&privKey->grp, &privKey->Q, pubkeyCoordsTlv->value + 1, 65)) { PrintAndLogEx(FAILED, "Failed to read in public key coordinates"); + tlvdb_free(derRoot); return PM3_EINVARG; } if (mbedtls_ecp_check_pubkey(&privKey->grp, &privKey->Q)) { PrintAndLogEx(FAILED, "VAS protocol requires an elliptic key on the P-256 curve"); + tlvdb_free(derRoot); return PM3_EINVARG; } + tlvdb_free(derRoot); return PM3_SUCCESS; }