Skip to content

Commit

Permalink
Merge pull request microsoft#143 from vadz:asio-mem-leak-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Jun 8, 2016
2 parents d79c9a0 + 12619af commit e8b3509
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Release/src/websockets/client/ws_client_wspp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@

#endif /* __GNUC__ */

// This is a hack to avoid memory leak reports from the debug MSVC CRT for all
// programs using the library: ASIO calls SSL_library_init() which calls
// SSL_COMP_get_compression_methods(), which allocates some heap memory and the
// only way to free it later is to call SSL_COMP_free_compression_methods(),
// but this function is unaccessible from the application code as OpenSSL is
// statically linked into the C++ REST SDK DLL. So, just to be nice, call it
// here ourselves -- even if the real problem is in ASIO (up to v1.60.0).
#if defined(_WIN32) && !defined(NDEBUG)

#include <openssl/ssl.h>
static struct ASIO_SSL_memory_leak_suppress
{
~ASIO_SSL_memory_leak_suppress()
{
::SSL_COMP_free_compression_methods();
}
} ASIO_SSL_memory_leak_suppressor;

#endif /* _WIN32 && !NDEBUG */

using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
Expand Down

0 comments on commit e8b3509

Please sign in to comment.