From: sooyeon.kim Date: Tue, 10 Oct 2017 10:35:03 +0000 (+0900) Subject: Fix coverity issues X-Git-Tag: accepted/tizen/unified/20180228.071749~37 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Ftts.git;a=commitdiff_plain;h=9c205f3fb26f025ba1a3c85a47c0504e16bd45fd Fix coverity issues Change-Id: I7778c652a98a4cfd11cfe5de64e26e209f8cb9fa Signed-off-by: sooyeon.kim --- diff --git a/client/tts.c b/client/tts.c index 1b07804..5580e97 100644 --- a/client/tts.c +++ b/client/tts.c @@ -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; } diff --git a/client/tts_dbus.c b/client/tts_dbus.c index 519a53e..44dc152 100644 --- a/client/tts_dbus.c +++ b/client/tts_dbus.c @@ -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) {