Skip to content

Commit 1a68f4b

Browse files
committed
Merge pull request XRPLF#335 from aydany/master
Require a valid con before calling terminate
2 parents b805689 + c3dfb25 commit 1a68f4b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

websocketpp/roles/server_endpoint.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ class server : public endpoint<connection<config>,config> {
110110
endpoint_type::m_elog.write(log::elevel::rerror,
111111
"start_accept error: "+ec.message());
112112
}
113-
114-
if (ec) {
115-
// Terminate the connection to prevent memory leaks.
116-
con->terminate(lib::error_code());
117-
}
118-
}
113+
114+
if (ec && con) {
115+
// Terminate the connection to prevent memory leaks.
116+
lib::error_code con_ec;
117+
con->terminate(con_ec);
118+
}
119+
}
119120

120121
void handle_accept(connection_ptr con, lib::error_code const & ec) {
121122
if (ec) {

0 commit comments

Comments
 (0)