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:
@@ -247,6 +247,15 @@ _libssh2_mbedtls_bignum_init(void)
|
|||||||
return bignum;
|
return bignum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_libssh2_mbedtls_bignum_free(_libssh2_bn *bn)
|
||||||
|
{
|
||||||
|
if (bn) {
|
||||||
|
mbedtls_mpi_free(bn);
|
||||||
|
mbedtls_free(bn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_libssh2_mbedtls_bignum_random(_libssh2_bn *bn, int bits, int top, int bottom)
|
_libssh2_mbedtls_bignum_random(_libssh2_bn *bn, int bits, int top, int bottom)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -307,7 +307,7 @@
|
|||||||
#define _libssh2_bn_bits(bn) \
|
#define _libssh2_bn_bits(bn) \
|
||||||
mbedtls_mpi_bitlen(bn)
|
mbedtls_mpi_bitlen(bn)
|
||||||
#define _libssh2_bn_free(bn) \
|
#define _libssh2_bn_free(bn) \
|
||||||
mbedtls_mpi_free(bn)
|
_libssh2_mbedtls_bignum_free(bn)
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user