From: srinivasa.m Date: Fri, 12 Jul 2019 12:40:27 +0000 (+0530) Subject: socket connection return value chack added to avoid crash X-Git-Tag: accepted/tizen/unified/20190715.111804^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F209953%2F1;p=platform%2Fcore%2Fsystem%2Fsensord.git socket connection return value chack added to avoid crash Change-Id: Ic63c3d4fbd1daad11f09d8d388522bd764241a11 --- 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(),