summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJi-Youn Park <jy0703.park@samsung.com>2016-09-20 16:14:04 +0830
committerJi-Youn Park <jy0703.park@samsung.com>2016-09-20 16:14:04 +0830
commit0a39fae0a2c27ec48b39caca3b00dc54bdffaa32 (patch)
treeac6ca0f1c8d948f4913ca651b695acb2caa9335d /src
parent078c4a9f11b2d13805b52b76cccc64485516103b (diff)
ecore_con_local: fix memory leak.
after socket function call, close file descriptor.
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_con/ecore_con_local.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index 1453ea103c..546b6e04a1 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -143,14 +143,14 @@ ecore_con_local_connect(Ecore_Con_Server *obj,
143 return 0; 143 return 0;
144 144
145 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) 145 if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
146 return 0; 146 goto error;
147 147
148 if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) 148 if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0)
149 return 0; 149 goto error;
150 150
151 if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, 151 if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate,
152 sizeof(curstate)) < 0) 152 sizeof(curstate)) < 0)
153 return 0; 153 goto error;
154 154
155 socket_unix.sun_family = AF_UNIX; 155 socket_unix.sun_family = AF_UNIX;
156 156
@@ -165,7 +165,7 @@ ecore_con_local_connect(Ecore_Con_Server *obj,
165 svr->name); 165 svr->name);
166#else 166#else
167 WRN("Your system does not support abstract sockets!"); 167 WRN("Your system does not support abstract sockets!");
168 return 0; 168 goto error;
169#endif 169#endif
170 } 170 }
171 else 171 else
@@ -179,12 +179,12 @@ ecore_con_local_connect(Ecore_Con_Server *obj,
179 socket_unix_len) < 0) 179 socket_unix_len) < 0)
180 { 180 {
181 DBG("local connection failed: %s", strerror(errno)); 181 DBG("local connection failed: %s", strerror(errno));
182 return 0; 182 goto error;
183 } 183 }
184 184
185 svr->path = strdup(buf); 185 svr->path = strdup(buf);
186 if (!svr->path) 186 if (!svr->path)
187 return 0; 187 goto error;
188 188
189 if (svr->type & ECORE_CON_SSL) 189 if (svr->type & ECORE_CON_SSL)
190 { 190 {
@@ -195,11 +195,15 @@ ecore_con_local_connect(Ecore_Con_Server *obj,
195 ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, 195 ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ,
196 cb_done, obj, NULL, NULL); 196 cb_done, obj, NULL, NULL);
197 if (!svr->fd_handler) 197 if (!svr->fd_handler)
198 return 0; 198 goto error;
199 199
200 if (!svr->delete_me) ecore_con_event_server_add(obj); 200 if (!svr->delete_me) ecore_con_event_server_add(obj);
201 201
202 return 1; 202 return 1;
203error:
204 if (svr->fd) close(svr->fd);
205 svr->fd = -1;
206 return 0;
203#endif 207#endif
204} 208}
205 209