From 1202c00fc79d89ea3bdff193b0b4e54125e0d2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 10 Oct 2019 08:45:14 +0300 Subject: [PATCH] MXS-2721: Check that LocalClient creation succeeds The creation can fail if a network socket cannot be opened and connected to the host in question. --- server/modules/protocol/MySQL/mysql_common.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/modules/protocol/MySQL/mysql_common.cc b/server/modules/protocol/MySQL/mysql_common.cc index 9f0b7a3b9..0fddc2801 100644 --- a/server/modules/protocol/MySQL/mysql_common.cc +++ b/server/modules/protocol/MySQL/mysql_common.cc @@ -1438,13 +1438,15 @@ static void worker_func(int thread_id, void* data) for (TargetList::iterator it = info->targets.begin(); it != info->targets.end(); it++) { - LocalClient* client = LocalClient::create(&info->session, &info->protocol, it->first); - GWBUF* buffer = modutil_create_query(it->second.c_str()); - client->queue_query(buffer); - gwbuf_free(buffer); + if (LocalClient* client = LocalClient::create(&info->session, &info->protocol, it->first)) + { + GWBUF* buffer = modutil_create_query(it->second.c_str()); + client->queue_query(buffer); + gwbuf_free(buffer); - // The LocalClient needs to delete itself once the queries are done - client->self_destruct(); + // The LocalClient needs to delete itself once the queries are done + client->self_destruct(); + } } delete info;