From 8776b414e863020bf8e84314bc7031cf9f56f797 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 10 Oct 2017 19:30:49 +0900 Subject: [PATCH] Fix coverity issues Change-Id: I275e4f2e56861f0617117f81ec2e9e4271bdcc7b Signed-off-by: sooyeon.kim --- client/stt.c | 20 ++++++++++++++++++-- server/sttd_dbus.c | 2 +- server/sttd_engine_agent.c | 1 - 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/client/stt.c b/client/stt.c index 178f26c..a986912 100644 --- a/client/stt.c +++ b/client/stt.c @@ -1633,8 +1633,15 @@ int stt_start(stt_h stt, const char* language, const char* type) temp = strdup(language); } + if (NULL == temp) { + SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory"); + return STT_ERROR_OUT_OF_MEMORY; + } + if (true == client->credential_needed && NULL == client->credential) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id); + free(temp); + temp = NULL; return STT_ERROR_PERMISSION_DENIED; } @@ -1647,7 +1654,8 @@ int stt_start(stt_h stt, const char* language, const char* type) SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is successful but not done"); } - if (NULL != temp) free(temp); + free(temp); + temp = NULL; SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); @@ -2543,8 +2551,15 @@ int stt_start_file(stt_h stt, const char* language, const char* type, const char temp = strdup(language); } + if (NULL == temp) { + SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory"); + return STT_ERROR_OUT_OF_MEMORY; + } + if (true == client->credential_needed && NULL == client->credential) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id); + free(temp); + temp = NULL; return STT_ERROR_PERMISSION_DENIED; } @@ -2557,7 +2572,8 @@ int stt_start_file(stt_h stt, const char* language, const char* type, const char SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is successful but not done"); } - if (NULL != temp) free(temp); + free(temp); + temp = NULL; SLOG(LOG_DEBUG, TAG_STTC, "====="); SLOG(LOG_DEBUG, TAG_STTC, " "); diff --git a/server/sttd_dbus.c b/server/sttd_dbus.c index a16e12c..fcc04ff 100644 --- a/server/sttd_dbus.c +++ b/server/sttd_dbus.c @@ -583,7 +583,7 @@ int __sttd_get_buxtonkey() __sttd_dbus_service_free(); - if (NULL == engine_appid || NULL == engine_default || 0 == strncmp(engine_appid, engine_default, strlen(engine_appid))) { + if (NULL == engine_default || 0 == strncmp(engine_appid, engine_default, strlen(engine_appid))) { g_server_service_name = (char*)calloc(strlen(STT_SERVER_SERVICE_NAME) + 1, sizeof(char)); if (g_server_service_name) snprintf(g_server_service_name, strlen(STT_SERVER_SERVICE_NAME) + 1, "%s", STT_SERVER_SERVICE_NAME); diff --git a/server/sttd_engine_agent.c b/server/sttd_engine_agent.c index 09b8269..8fa4ca7 100644 --- a/server/sttd_engine_agent.c +++ b/server/sttd_engine_agent.c @@ -780,7 +780,6 @@ int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const ch if (NULL != temp) free(temp); if (0 != ret) { SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Recognition start error(%d)", ret); - sttd_recorder_destroy(); return ret; } -- 2.7.4