Fix coverity issues
[platform/core/uifw/tts.git] / client / tts.c
index 1b07804..5580e97 100644 (file)
@@ -528,6 +528,10 @@ int tts_set_server_tts(tts_h tts, const char* credential)
                client->credential = strdup(credential);
                if (NULL == client->credential) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
+                       if (NULL != key) {
+                               free(key);
+                               key = NULL;
+                       }
                        return TTS_ERROR_OUT_OF_MEMORY;
                }
        } else {
@@ -542,10 +546,14 @@ int tts_set_server_tts(tts_h tts, const char* credential)
        int pid = getpid();
        char* appid = NULL;
        int ret = app_manager_get_app_id(pid, &appid);
-       if (0 != ret) {
+       if (0 != ret || NULL == appid) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get appid, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
                free(key);
                key = NULL;
+               if (NULL != appid) {
+                       free(appid);
+                       appid = NULL;
+               }
                return TTS_ERROR_OPERATION_FAILED;
        }
 
@@ -554,6 +562,8 @@ int tts_set_server_tts(tts_h tts, const char* credential)
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set private data, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
                free(key);
                key = NULL;
+               free(appid);
+               appid = NULL;
                return ret;
        }