socket connection return value chack added to avoid crash 53/209953/1 accepted/tizen/unified/20190715.111804 submit/tizen/20190715.043735
authorsrinivasa.m <srinivasa.m@samsung.com>
Fri, 12 Jul 2019 12:40:27 +0000 (18:10 +0530)
committersrinivasa.m <srinivasa.m@samsung.com>
Fri, 12 Jul 2019 12:40:27 +0000 (18:10 +0530)
Change-Id: Ic63c3d4fbd1daad11f09d8d388522bd764241a11

src/shared/ipc_client.cpp

index f021784..ea86baf 100644 (file)
@@ -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(),