From dfc6e77b1d0760f82773b7670f13ce41793fff7e Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 22 Jun 2016 13:34:41 +0900 Subject: [PATCH] Add memory check Change-Id: I9b71a9b230265783c1349b97b0fcca78a4eadc48 --- server/ttsd_engine_agent.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/server/ttsd_engine_agent.c b/server/ttsd_engine_agent.c index 8074660..c1d5fe5 100644 --- a/server/ttsd_engine_agent.c +++ b/server/ttsd_engine_agent.c @@ -296,14 +296,34 @@ int ttsd_engine_agent_initialize_current_engine() iter = g_list_first(g_engine_list); else { SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] NO TTS Engine !!"); - if (NULL != cur_engine_uuid) free(cur_engine_uuid); + if (NULL != cur_engine_uuid) { + free(cur_engine_uuid); + cur_engine_uuid = NULL; + } return TTSD_ERROR_OPERATION_FAILED; } - if (cur_engine_uuid != NULL) free(cur_engine_uuid); + if (NULL == iter) { + SLOG(LOG_WARN, get_tag(), "[Engine Agent ERROR] No valid TTS Engine"); + if (NULL != cur_engine_uuid) { + free(cur_engine_uuid); + cur_engine_uuid = NULL; + } + return TTSD_ERROR_OPERATION_FAILED; + } + + if (cur_engine_uuid != NULL) { + free(cur_engine_uuid); + cur_engine_uuid = NULL; + } ttsengine_info_s *data = NULL; data = iter->data; + if (NULL == data || NULL == data->engine_uuid) { + SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No valid TTS Engine"); + return TTSD_ERROR_OPERATION_FAILED; + } + cur_engine_uuid = strdup(data->engine_uuid); is_get_engineid_from_config = false; @@ -1723,4 +1743,4 @@ int ttsd_print_voicelist() SLOG(LOG_DEBUG, get_tag(), "=================="); return 0; -} \ No newline at end of file +} -- 2.7.4