Fix coverity issues 11/154511/2
authorsooyeon.kim <sooyeon.kim@samsung.com>
Tue, 10 Oct 2017 10:35:03 +0000 (19:35 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Wed, 11 Oct 2017 08:26:59 +0000 (17:26 +0900)
Change-Id: I7778c652a98a4cfd11cfe5de64e26e209f8cb9fa
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
client/tts.c
client/tts_dbus.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;
        }
 
index 519a53e..44dc152 100644 (file)
@@ -418,6 +418,11 @@ int tts_dbus_request_initialize(int uid, bool* credential_needed)
                        /* add a rule for daemon error */
                        char rule_err[256] = {0, };
                        tts_client_s* client = tts_client_get_by_uid(uid);
+                       if (NULL == client) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get TTS client");
+                               return TTS_ERROR_OPERATION_FAILED;
+                       }
+
                        if (TTS_MODE_DEFAULT == client->mode) {
                                snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_SERVER_SERVICE_INTERFACE);
                        } else if (TTS_MODE_NOTIFICATION == client->mode) {
@@ -455,6 +460,11 @@ int tts_dbus_request_finalize(int uid)
        /* remove a rule for daemon error */
        char rule_err[256] = {0, };
        tts_client_s* client = tts_client_get_by_uid(uid);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Fail to get TTS client");
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
        if (TTS_MODE_DEFAULT == client->mode) {
                snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", TTS_SERVER_SERVICE_INTERFACE);
        } else if (TTS_MODE_NOTIFICATION == client->mode) {