Fix memory leak 21/94421/1 accepted/tizen/3.0/ivi/20161102.075726 accepted/tizen/3.0/mobile/20161102.075515 accepted/tizen/3.0/tv/20161102.075624 accepted/tizen/3.0/wearable/20161102.075655 accepted/tizen/common/20161031.121629 accepted/tizen/ivi/20161031.082307 accepted/tizen/mobile/20161031.082135 accepted/tizen/tv/20161031.082227 accepted/tizen/wearable/20161031.082248 submit/tizen/20161031.010650 submit/tizen_3.0/20161102.051512
authorHwankyu Jhun <h.jhun@samsung.com>
Sun, 30 Oct 2016 22:55:38 +0000 (07:55 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Sun, 30 Oct 2016 22:55:38 +0000 (07:55 +0900)
Change-Id: I4b88aca7d9b24679356ac05b0b591cba22ce7ce0
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
plugin/app2sd/src/app2sd_internals.c

index b2cba3e..dfa8989 100644 (file)
@@ -424,7 +424,7 @@ int _app2sd_dmcrypt_open_device(const char *pkgid, const char *loopback_device,
                bool is_dup, uid_t uid, char **dev_node)
 {
        int ret = APP2EXT_SUCCESS;
-       char *passwd = NULL;
+       char *passwd;
        char dmcrypt_open_cmd[BUF_SIZE] = { 0, };
        char dev_name[BUF_SIZE] = { 0, };
        char buf[BUF_SIZE] = { 0, };
@@ -446,13 +446,16 @@ int _app2sd_dmcrypt_open_device(const char *pkgid, const char *loopback_device,
                _E("app2sd db initialize failed");
                return APP2EXT_ERROR_DB_INITIALIZE;
        }
-       if ((passwd = _app2sd_get_password_from_db(pkgid, uid)) == NULL) {
+
+       passwd = _app2sd_get_password_from_db(pkgid, uid);
+       if (passwd == NULL) {
                _E("no password found for [%s]", pkgid);
                return APP2EXT_ERROR_SQLITE_REGISTRY;
        }
 
        snprintf(dmcrypt_open_cmd, BUF_SIZE, "/bin/echo '%s' | /sbin/cryptsetup -q luksOpen %s %s",
                passwd, loopback_device, dev_name);
+       free(passwd);
 
        ret = system(dmcrypt_open_cmd);
        if (ret) {