espressif / esp-nimble

A fork of NimBLE stack, for use with ESP32 and ESP-IDF
Apache License 2.0
76 stars 49 forks source link

memory leaking in provisioning procedure for mesh provisioner #38

Closed justabetterman closed 1 year ago

justabetterman commented 2 years ago

I found a memory leaking issue caused by mbedtls_gen_keypair as below, i think mbedtls_ecp_keypair_free should be invoked regardless of the rc vaule.

exit: mbedtls_ctr_drbg_free( &ctr_drbg ); mbedtls_entropy_free( &entropy ); if (rc != 0) { mbedtls_ecp_keypair_free(&keypair); return BLE_HS_EUNKNOWN; }

the memory leaking issue can be observed when device works as a mesh provisioner and finish provisioning node device many times.

rahult-github commented 2 years ago

keypair is a static variable which gets inited everytime. There should be a check to free the keypair (if it is already allocated) . Will add this check.

rahult-github commented 1 year ago

This commit address the issue. Sorry for delay in update.