1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

fix memory leak when using mbedtls backend (#158)

_libssh2_bn_init_from_bin/_libssh2_bn_free would leak bignum from mbedtls_calloc().
This commit is contained in:
doublex
2018-04-18 19:58:35 +02:00
committed by Will Cosgrove
parent 498a5f5b3f
commit 8abc686f0e
2 changed files with 10 additions and 1 deletions

View File

@@ -247,6 +247,15 @@ _libssh2_mbedtls_bignum_init(void)
return bignum;
}
void
_libssh2_mbedtls_bignum_free(_libssh2_bn *bn)
{
if (bn) {
mbedtls_mpi_free(bn);
mbedtls_free(bn);
}
}
static int
_libssh2_mbedtls_bignum_random(_libssh2_bn *bn, int bits, int top, int bottom)
{

View File

@@ -307,7 +307,7 @@
#define _libssh2_bn_bits(bn) \
mbedtls_mpi_bitlen(bn)
#define _libssh2_bn_free(bn) \
mbedtls_mpi_free(bn)
_libssh2_mbedtls_bignum_free(bn)
/*******************************************************************/