From abd2f759ae04f76b1fc1d06c7a875d30496d2665 Mon Sep 17 00:00:00 2001 From: kormax Date: Mon, 10 Jul 2023 10:34:08 +0300 Subject: [PATCH] Fix potential memory leak in VAS implementation --- client/src/cmdhfvas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhfvas.c b/client/src/cmdhfvas.c index 839474cc5..034118d39 100644 --- a/client/src/cmdhfvas.c +++ b/client/src/cmdhfvas.c @@ -187,10 +187,9 @@ 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; } @@ -199,6 +198,7 @@ static int LoadReaderPrivateKey(uint8_t *buf, size_t bufLen, mbedtls_ecp_keypair return PM3_EINVARG; } + tlvdb_free(derRoot); return PM3_SUCCESS; }