Fix memory leak 61/72861/1
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 2 Jun 2016 23:36:16 +0000 (08:36 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 2 Jun 2016 23:36:16 +0000 (08:36 +0900)
Change-Id: Idd6f721ba85836255211fc9064d5be963c8074e5
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
tool/app_launcher.c

index f7ddf53..0dba888 100644 (file)
@@ -360,13 +360,16 @@ static void __watch_amd_ready(const char *appid, int pid)
                return;
 
        watch->appid = strdup(appid);
-       if (watch->appid == NULL)
+       if (watch->appid == NULL) {
+               free(watch);
                return;
+       }
 
        watch->pid = pid;
 
        watch->fd = inotify_init();
        if (watch->fd < 0) {
+               free(watch->appid);
                free(watch);
                return;
        }
@@ -374,6 +377,7 @@ static void __watch_amd_ready(const char *appid, int pid)
        watch->wd = inotify_add_watch(watch->fd, buf, IN_CREATE);
        if (watch->wd < 0) {
                close(watch->fd);
+               free(watch->appid);
                free(watch);
                return;
        }
@@ -382,6 +386,7 @@ static void __watch_amd_ready(const char *appid, int pid)
        if (watch->io == 0) {
                inotify_rm_watch(watch->fd, watch->wd);
                close(watch->fd);
+               free(watch->appid);
                free(watch);
                return;
        }