Fix PASSED_TO_PROC_AFTER_FREE issue
[platform/core/uifw/tts.git] / common / tts_config_mgr.c
old mode 100644 (file)
new mode 100755 (executable)
index 2a53f61..8259e2c
@@ -771,6 +771,9 @@ int __tts_config_mgr_get_engine_info()
                        }
 
                        if (NULL != dirp) {
+                               if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
+                                       continue;
+
                                filesize = strlen(TTS_DEFAULT_ENGINE_INFO) + strlen(dirp->d_name) + 2;
                                if (filesize >= 512) {
                                        SECURE_SLOG(LOG_ERROR, tts_tag(), "[CONFIG ERROR] File path is too long : %s", dirp->d_name);
@@ -810,6 +813,9 @@ int __tts_config_mgr_get_engine_info()
                        }
 
                        if (NULL != dirp) {
+                               if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
+                                       continue;
+
                                filesize = strlen(TTS_DOWNLOAD_ENGINE_INFO) + strlen(dirp->d_name) + 2;
                                if (filesize >= 512) {
                                        SECURE_SLOG(LOG_ERROR, tts_tag(), "[CONFIG ERROR] File path is too long : %s", dirp->d_name);
@@ -942,12 +948,16 @@ static int __tts_config_mgr_register_engine_config_updated_event(const char* pat
        SLOG(LOG_DEBUG, tts_tag(), "Add inotify watch(%s)", path);
        if (ino->dir_wd < 0) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to add watch");
+               free(ino);
+               ino = NULL;
                return -1;
        }
 
        ino->dir_fd_handler = ecore_main_fd_handler_add(ino->dir_fd, ECORE_FD_READ, (Ecore_Fd_Cb)__tts_config_mgr_engine_config_inotify_event_callback, (void *)ino, NULL, NULL);
        if (NULL == ino->dir_fd_handler) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to add fd handler");
+               free(ino);
+               ino = NULL;
                return -1;
        }
 
@@ -1394,7 +1404,7 @@ int __tts_set_buxtonkey(const char* engine)
                SLOG(LOG_ERROR, tts_tag(), "[DBUS-BUXTON2] buxton_open failed!! (%d)", ret);
                return TTS_CONFIG_ERROR_OPERATION_FAILED;
        }
-       bux_layer = buxton_create_layer("user");
+       bux_layer = buxton_create_layer("system");
        if (NULL == bux_layer) {
                SLOG(LOG_ERROR, tts_tag(), "[DBUS-BUXTON2] buxton_create_layer FAIL");
                buxton_close(bux_cli);
@@ -1493,11 +1503,13 @@ int tts_config_mgr_set_engine(const char* engine)
 
                g_config_info->engine_id = strdup(engine);
 
-               if (NULL != g_config_info->setting)
-                       free(g_config_info->setting);
-
-               if (NULL != engine_info->setting)
+               if (NULL != engine_info->setting) {
+                       if (NULL != g_config_info->setting) {
+                               free(g_config_info->setting);
+                               g_config_info->setting = NULL;
+                       }
                        g_config_info->setting = strdup(engine_info->setting);
+               }
 
                /* Engine is valid*/
                GSList *iter_voice = NULL;