Fix coverity issues 11/260711/2 accepted/tizen/unified/20210702.133343 submit/tizen/20210701.200247
authorsooyeon <sooyeon.kim@samsung.com>
Thu, 1 Jul 2021 19:29:39 +0000 (04:29 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Thu, 1 Jul 2021 19:53:17 +0000 (04:53 +0900)
* No lock
* No memory release

Change-Id: I6de64422ee6b610d99cd6dbe1cad232bcb855f9d
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
server/ttsd_player.c
tests/src/tts_unittests.cpp

index da4edff32a5d00afeaa085ab200092bce4a53cc1..acd60eb927f6e13732ffe04019f1e88bfa044e61 100644 (file)
@@ -1037,6 +1037,7 @@ int __create_ducking_handle(void)
 */
 int ttsd_player_init()
 {
+       pthread_mutex_lock(&g_player_control_mutex);
        g_playing_info = NULL;
        g_audio_state = AUDIO_STATE_NONE;
        g_audio_h = NULL;
@@ -1060,6 +1061,7 @@ int ttsd_player_init()
        ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOICE_INFORMATION, __player_focus_state_cb, NULL, &g_stream_info_h);
        if (SOUND_MANAGER_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to create stream info");
+               pthread_mutex_unlock(&g_player_control_mutex);
                return -1;
        } else {
                SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Create stream info");
@@ -1071,6 +1073,7 @@ int ttsd_player_init()
                SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to add sound focus watch callback");
                sound_manager_destroy_stream_information(g_stream_info_h);
                g_stream_info_h = NULL;
+               pthread_mutex_unlock(&g_player_control_mutex);
                return -1;
        } else {
                SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Add sound focus watch callback");
@@ -1091,12 +1094,15 @@ int ttsd_player_init()
                sound_manager_remove_focus_state_watch_cb(g_focus_watch_id);
                g_stream_info_h = NULL;
                g_focus_watch_id = -1;
+               pthread_mutex_unlock(&g_player_control_mutex);
 
                return -1;
        }
 
        g_player_init = true;
 
+       pthread_mutex_unlock(&g_player_control_mutex);
+
        return 0;
 }
 
index c4c4ea0e88a866c635ca9f0c3fb668338a8a691c..a30a0e2c2e9e0c9f17b706c1dc16e17d3b5dfb4a 100644 (file)
@@ -1571,6 +1571,7 @@ TEST_F(TTSTest, utc_tts_repeat_p)
        EXPECT_EQ(ret, TTS_ERROR_NONE);
 
        ret = strncmp(text_repeat, "repeat success", strlen(text_repeat));
+       free(text_repeat);
        EXPECT_EQ(ret, 0);
 
        EXPECT_EQ(true, __is_state_changed(TTS_STATE_PLAYING, 5));