From: VBS Date: Tue, 21 Jan 2025 09:35:57 +0000 (+0900) Subject: Fix double fclose issue X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=529f939deb19c062917b4c9af5675ee3cfd485f1;p=platform%2Fcore%2Fuifw%2Ftts.git Fix double fclose issue Change-Id: I9468d805475f54e1755c3dcc5e219e923f9ac221 Signed-off-by: VBS --- diff --git a/common/tts_config_mgr.c b/common/tts_config_mgr.c index 5061f7bb..6145ab3f 100644 --- a/common/tts_config_mgr.c +++ b/common/tts_config_mgr.c @@ -919,10 +919,9 @@ static int set_voice_by_automation(int allowed_type_flag) SLOG(LOG_ERROR, TAG_TTSCONFIG, "[INFO] voice changed event was invoked. language(%s), type(%d), selected language(%s), selected type(%d), auto_voice(%d)", config_info.language, config_info.type, selected_language, selected_type, (int)config_info.auto_voice); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client is not allowed to save configuration. Skip saving configuration file."); + close(fd); } - close(fd); - set_voice_into_config(&config_info, selected_language, selected_type); if (0 != tts_parser_set_config_info(&config_info)){ @@ -1459,6 +1458,7 @@ int tts_config_mgr_initialize(unsigned int uid, tts_config_client_type_e client_ tts_parser_save_with_flock(fd); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } if (0 != tts_parser_set_config_info(&config_info)) { @@ -1466,12 +1466,15 @@ int tts_config_mgr_initialize(unsigned int uid, tts_config_client_type_e client_ close(fd); return TTS_CONFIG_ERROR_OPERATION_FAILED; } + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] tmp_language is NULL"); + close(fd); } + } else { + close(fd); } - close(fd); } - /* print daemon config */ SLOG(LOG_ERROR, TAG_TTSCONFIG, "@@@ TTS config @@@"); SECURE_SLOG(LOG_ERROR, TAG_TTSCONFIG, " engine : %s", config_info.engine_id); @@ -1789,6 +1792,7 @@ int tts_config_mgr_set_engine(const char* engine) SLOG(LOG_INFO, TAG_TTSCONFIG, "vconf engine id(%s) is different from input engine id(%s)", engine, engine_id); ret = __tts_set_buxtonkey(engine); if (0 != ret) { + close(fd); SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] set_buxtonkey Fail!!"); return ret; } @@ -1837,10 +1841,9 @@ int tts_config_mgr_set_engine(const char* engine) invoke_engine_changed_event(config_info.engine_id, config_info.setting, config_info.language, config_info.type, config_info.auto_voice, config_info.credential); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } - close(fd); - if (0 != tts_parser_set_config_info(&config_info)) { SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to set configure information"); return TTS_CONFIG_ERROR_OPERATION_FAILED; @@ -1977,10 +1980,9 @@ int tts_config_mgr_set_voice(const char* language, int type) invoke_voice_changed_event(config_info.language, config_info.type, language, type, config_info.auto_voice); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } - close(fd); - set_voice_into_config(&config_info, language, type); if (0 != tts_parser_set_config_info(&config_info)){ @@ -2050,10 +2052,9 @@ int tts_config_mgr_set_auto_voice(bool value) tts_parser_save_with_flock(fd); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } - close(fd); - config_info.auto_voice = value; if (0 != tts_parser_set_config_info(&config_info)) { SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to set configure information"); @@ -2134,10 +2135,9 @@ int tts_config_mgr_set_speech_rate(int value) invoke_speech_rate_changed_event(value); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } - close(fd); - config_info.speech_rate = value; if (0 != tts_parser_set_config_info(&config_info)){ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to set configure information"); @@ -2236,10 +2236,9 @@ int tts_config_mgr_set_pitch(int value) invoke_pitch_changed_event(value); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } - close(fd); - config_info.pitch = value; if (0 != tts_parser_set_config_info(&config_info)){ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to set configure information"); @@ -2303,10 +2302,9 @@ int tts_config_mgr_set_bg_volume_ratio(double value) invoke_bg_volume_ratio_changed_event(value); } else { SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type is default. Skip saving configuration file."); + close(fd); } - close(fd); - if (config_info.bg_volume_ratio == value) { SLOG(LOG_INFO, TAG_TTSCONFIG, "Background volume(%lf) is not changed. Skip setting", value); return TTS_CONFIG_ERROR_NONE; diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index 75b38133..5c9451b1 100644 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -1253,7 +1253,8 @@ int tts_parser_save_with_flock(int fd) static FILE* pFile; pFile = fdopen(fd, "w"); if (NULL == pFile) { - SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to open file %s (by %d)", TTS_CONFIG, errno); + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to open file %s (by %d). Call close(fd)", TTS_CONFIG, errno); + close(fd); return -1; } @@ -1263,7 +1264,7 @@ int tts_parser_save_with_flock(int fd) SLOG(LOG_ERROR, TAG_TTSCONFIG, "[INFO] xml_buff(%s)", xml_buff); fprintf(pFile, "%s", (char*)xml_buff); fclose(pFile); - SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Success to save %s", TTS_CONFIG); + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Success to save %s and fclose file pointer", TTS_CONFIG); xmlFree(xml_buff);