diff options
author | Myungki Lee <mk5004.lee@samsung.com> | 2015-12-24 17:21:46 +0900 |
---|---|---|
committer | MyungKi Lee <mk5004.lee@samsung.com> | 2015-12-29 14:14:21 -0800 |
commit | ab571578c6f182dffe284faee198c46e1bf3d203 (patch) | |
tree | 945551b0a5af639af4463fe441f0569b885fcc7c | |
parent | a36d13a8cb92cd895ce6008ad623ae69b6cf9234 (diff) | |
download | launchpad-ab571578c6f182dffe284faee198c46e1bf3d203.tar.gz launchpad-ab571578c6f182dffe284faee198c46e1bf3d203.tar.bz2 launchpad-ab571578c6f182dffe284faee198c46e1bf3d203.zip |
Fix memory leak
Change-Id: I5e67478ffe1db5b40821536503be4a8f302f7e02
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
-rwxr-xr-x | src/launchpad.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/launchpad.c b/src/launchpad.c index a5a1dfa..3bdaa4d 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -995,13 +995,14 @@ end: static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path) { - candidate_process_context_t *cpc = (candidate_process_context_t*)malloc(sizeof(candidate_process_context_t)); + candidate_process_context_t *cpc; int fd = -1; - if (cpc == NULL) + if (__find_slot(type, loader_id) != NULL) return NULL; - if (__find_slot(type, loader_id) != NULL) + cpc = (candidate_process_context_t*)malloc(sizeof(candidate_process_context_t)); + if (cpc == NULL) return NULL; cpc->type = type; @@ -1019,11 +1020,13 @@ static candidate_process_context_t* __add_slot(int type, int loader_id, int call if (fd == -1) { _E("[launchpad] Listening the socket to the type %d candidate process failed.", cpc->type); + free(cpc); return NULL; } if (__poll_fd(fd, G_IO_IN, (GSourceFunc)__handle_loader_event, cpc->type, cpc->loader_id) < 0) { close(fd); + free(cpc); return NULL; } |