Fix defects detected by static analysis tool 70/258770/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 25 May 2021 10:22:25 +0000 (19:22 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 25 May 2021 10:26:01 +0000 (19:26 +0900)
Change-Id: I69a5ebb8595610b00c162ec6401ea29d357407e8

assistant-parser/src/ma_assistant_parser.c

index adc1e63da039219221727ff8bd972b7dff1c3a46..51710b5ecb2380904866b58ee01eb0484515e8b2 100644 (file)
@@ -299,11 +299,9 @@ static int __remove_assistant_info_xml(const char *pkgid, gchar *ut, uid_t uid)
 
        char path[256] = {'\0',};
        snprintf(path, 256, "%s/%s.xml", dir_assistant_info, pkgid);
-       if (0 == access(path, F_OK)) {
-               LOGD("Remove assistant info xml(%s)", path);
-               if (0 != remove(path)) {
-                       LOGE("[ERROR] Fail to remove assistant info xml(%s)", path);
-               }
+       LOGD("Remove assistant info xml(%s)", path);
+       if (0 != remove(path)) {
+               LOGE("[ERROR] Fail to remove assistant info xml(%s)", path);
        }
 
        FREE(dir_assistant_info)
@@ -643,6 +641,10 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList *
                        if (NULL != home_dir) {
                                LOGD("[DEBUG] uid(%d), gid(%d), user_type(%s), home_dir(%s)", uid, gid, user_type, home_dir);
 
+                               FREE(g_dir_config_base)
+                               FREE(g_dir_home)
+                               FREE(g_dir_assistant_base)
+                               FREE(g_dir_assistant_info)
                                g_dir_config_base = (char*)calloc(strlen(home_dir) + 23, sizeof(char));
                                g_dir_home = (char*)calloc(strlen(home_dir) + 26, sizeof(char));
                                g_dir_assistant_base = (char*)calloc(strlen(home_dir) + 30, sizeof(char));
@@ -956,6 +958,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList
                        printf("[Parser Debug][DEBUG] TZ_USER_HOME: %s", tzplatform_mkstr(TZ_USER_HOME, "/"));
                }
 
+               FREE(g_dir_assistant_info);
                g_dir_assistant_info = strdup(MA_ASSISTANT_INFO);
                if (NULL == g_dir_assistant_info) {
                        LOGE("[ERROR] Fail to allocate memory");