From ad68639a7bd74b8a4800168fc8963ab98bf7d716 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 11 Feb 2013 14:50:45 +0800 Subject: [PATCH] valgrind openssl destroy as far as possible OpenSSL doesn't seem to have a way to close out three allocations it creates during SSL library init. Even after doing the magic incantations suggested on the openssl list, we're left with these. Well, 88 bytes from ssl init is probably not critical, but it's annoying ==15206== HEAP SUMMARY: ==15206== in use at exit: 88 bytes in 3 blocks ==15206== total heap usage: 13,566 allocs, 13,563 frees, 5,933,134 bytes allocated ==15206== ==15206== 24 bytes in 1 blocks are still reachable in loss record 1 of 3 ==15206== at 0x4A06409: malloc (vg_replace_malloc.c:270) ==15206== by 0x3014C612B2: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1c) ==15206== by 0x3015441B38: ??? (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x3015443A78: SSL_COMP_get_compression_methods (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x301544932B: SSL_library_init (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x4C340D4: libwebsocket_create_context (libwebsockets.c:1796) ==15206== by 0x401C08: main (in /usr/bin/libwebsockets-test-server) ==15206== ==15206== 32 bytes in 1 blocks are still reachable in loss record 2 of 3 ==15206== at 0x4A06409: malloc (vg_replace_malloc.c:270) ==15206== by 0x3014C612B2: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1c) ==15206== by 0x3014CC91BE: sk_new (in /usr/lib64/libcrypto.so.1.0.1c) ==15206== by 0x3015441AF9: ??? (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x3015443A78: SSL_COMP_get_compression_methods (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x301544932B: SSL_library_init (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x4C340D4: libwebsocket_create_context (libwebsockets.c:1796) ==15206== by 0x401C08: main (in /usr/bin/libwebsockets-test-server) ==15206== ==15206== 32 bytes in 1 blocks are still reachable in loss record 3 of 3 ==15206== at 0x4A06409: malloc (vg_replace_malloc.c:270) ==15206== by 0x3014C612B2: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1c) ==15206== by 0x3014CC91DC: sk_new (in /usr/lib64/libcrypto.so.1.0.1c) ==15206== by 0x3015441AF9: ??? (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x3015443A78: SSL_COMP_get_compression_methods (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x301544932B: SSL_library_init (in /usr/lib64/libssl.so.1.0.1c) ==15206== by 0x4C340D4: libwebsocket_create_context (libwebsockets.c:1796) ==15206== by 0x401C08: main (in /usr/bin/libwebsockets-test-server) ==15206== ==15206== LEAK SUMMARY: ==15206== definitely lost: 0 bytes in 0 blocks ==15206== indirectly lost: 0 bytes in 0 blocks ==15206== possibly lost: 0 bytes in 0 blocks ==15206== still reachable: 88 bytes in 3 blocks ==15206== suppressed: 0 bytes in 0 blocks Signed-off-by: Andy Green --- lib/libwebsockets.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index b1b2917..48ea51a 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1090,6 +1090,11 @@ libwebsocket_context_destroy(struct libwebsocket_context *context) SSL_CTX_free(context->ssl_ctx); if (context->ssl_client_ctx) SSL_CTX_free(context->ssl_client_ctx); + + ERR_remove_state(0); + ERR_free_strings(); + EVP_cleanup(); + CRYPTO_cleanup_all_ex_data(); #endif if (context->fds) -- 2.7.4