Fix coverity issues 07/154507/3
authorsooyeon.kim <sooyeon.kim@samsung.com>
Tue, 10 Oct 2017 10:30:49 +0000 (19:30 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Wed, 11 Oct 2017 08:49:28 +0000 (17:49 +0900)
Change-Id: I275e4f2e56861f0617117f81ec2e9e4271bdcc7b
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/stt.c
server/sttd_dbus.c
server/sttd_engine_agent.c

index 178f26c..a986912 100644 (file)
@@ -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, " ");
index a16e12c..fcc04ff 100644 (file)
@@ -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);
index 09b8269..8fa4ca7 100644 (file)
@@ -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;
        }