eduardsui / tlse

Single C file TLS 1.2/1.3 implementation, using tomcrypt as crypto library
Other
544 stars 90 forks source link

Memory leaks in 'tlse.c' #27

Closed pjotawake closed 6 years ago

pjotawake commented 6 years ago

When checking with "valgrind --leak-check=full", it seems some memory leaks are detected:

==30771== 38,400 bytes in 1 blocks are definitely lost in loss record 41 of 50 ==30771== at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==30771== by 0x44B2F9: tls_load_root_certificates (tlse.c:9525) ==30771== by 0x44BBEC: SSL_CTX_root_ca (tlse.c:9869) ==30771== by 0x44FF61: SSL_CONNECT (ssl.SSL_CONNECT.h:31) ==30771== ==30771== 256,122 bytes in 1 blocks are definitely lost in loss record 42 of 50 ==30771== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==30771== by 0x44BB8D: SSL_CTX_root_ca (tlse.c:9865) ==30771== by 0x44FF61: SSL_CONNECT (ssl.SSL_CONNECT.h:31)

The latter can easily be fixed by adding a 'TLS_FREE(buf)' at line 9883 but I guess this is not the preferred way?

eduardsui commented 6 years ago

Thanks for reporting this. I think I fixed it, but I cannot test it now. Can you confirm it is OK?

pjotawake commented 6 years ago

Thanks, that is fast! And indeed, your fixes solve the issue. All OK on my side now.

eduardsui commented 6 years ago

Can we close this?

pjotawake commented 6 years ago

Yes, it can be closed.