From ed4d42656134e1c64bb25343cf6e7c4d40bc33c4 Mon Sep 17 00:00:00 2001 From: "srinivasa.m" Date: Fri, 12 Jul 2019 18:10:27 +0530 Subject: [PATCH] socket connection return value chack added to avoid crash Change-Id: Ic63c3d4fbd1daad11f09d8d388522bd764241a11 --- src/shared/ipc_client.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/shared/ipc_client.cpp b/src/shared/ipc_client.cpp index f021784..ea86baf 100644 --- a/src/shared/ipc_client.cpp +++ b/src/shared/ipc_client.cpp @@ -52,10 +52,10 @@ channel *ipc_client::connect(channel_handler *handler) channel *ipc_client::connect(channel_handler *handler, event_loop *loop, bool bind) { - socket *sock; - channel *ch; - channel_event_handler *ev_handler; - + socket *sock = NULL; + channel *ch = NULL; + channel_event_handler *ev_handler = NULL; + bool ret = false; retvm_if(access(m_path.c_str(), F_OK), NULL, "Failed to access to %s", m_path.c_str()); @@ -82,7 +82,14 @@ channel *ipc_client::connect(channel_handler *handler, event_loop *loop, bool bi return NULL; } - ch->connect(ev_handler, loop); + ret = ch->connect(ev_handler, loop); + if(ret == false) { + delete ch; + delete sock; + delete ev_handler; + _E("Faield to connect"); + return NULL; + } if (loop && bind) { uint64_t id = loop->add_event(sock->get_fd(), -- 2.7.4