From 5a5d8321bd870a33cc92609ada2e06d3b50875db Mon Sep 17 00:00:00 2001 From: Aydan Yumerefendi Date: Tue, 4 Mar 2014 21:02:42 -0500 Subject: [PATCH] Require a valid con before calling terminate If get_connection returns null, e.g., if during stop the tls_init handler is removed from the server, con->terminate will cause a crash. --- websocketpp/roles/server_endpoint.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websocketpp/roles/server_endpoint.hpp b/websocketpp/roles/server_endpoint.hpp index 9ebb109897..d29673cab8 100644 --- a/websocketpp/roles/server_endpoint.hpp +++ b/websocketpp/roles/server_endpoint.hpp @@ -105,7 +105,7 @@ public: "start_accept error: "+ec.message()); } - if (ec) { + if (ec && con) { // Terminate the connection to prevent memory leaks. lib::error_code con_ec; con->terminate(con_ec);