Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

Fix memory leaks if handshake fails

Open zefir-o opened this issue 2 years ago • 3 comments

zefir-o avatar Oct 16 '23 07:10 zefir-o

This way we lose last bearssl error since you delete the context obj with _freeSSL() call. You might want to save result of br_ssl_engine_last_error some place beforehand https://github.com/esp8266/Arduino/blob/1662248b394740d82824f504a021d4dad3d314b6/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp#L1347

mcspr avatar Oct 16 '23 19:10 mcspr

This way we lose last bearssl error since you delete the context obj with _freeSSL() call. You might want to save result of br_ssl_engine_last_error some place beforehand

https://github.com/esp8266/Arduino/blob/1662248b394740d82824f504a021d4dad3d314b6/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp#L1347

@mcspr Thank you for the hint. It was done similarly to existing code: https://github.com/esp8266/Arduino/blob/1662248b394740d82824f504a021d4dad3d314b6/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp#L1188

zefir-o avatar Oct 16 '23 20:10 zefir-o

@igor-epam What do you think of saving the content of br_ssl_engine_last_error in a "releaseSSL()" method that would also call _freeSSL() ?

d-a-v avatar Mar 25 '24 21:03 d-a-v