Avoid crash when pid is nagative value 07/223607/1
authorwn.jang <wn.jang@samsung.com>
Thu, 30 Jan 2020 12:23:38 +0000 (21:23 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Fri, 31 Jan 2020 06:40:56 +0000 (06:40 +0000)
Change-Id: I31a41af85b934a76f4c9bd09c9cdc8321c2659ac

server/ttsd_server.c

index 8ba5724..d90380a 100644 (file)
@@ -156,15 +156,18 @@ int ttsd_send_error(ttse_error_e error, const char* msg)
        if (0 != ttsd_data_clear_data(uid))
                SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_data_clear_data()");
 
-       if (0 != ttsdc_send_error_message(tmp_pid, uid, uttid, error, (char*)msg))
-               SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsdc_send_error_message()");
+       if (tmp_pid > 0) {
+               if (0 != ttsdc_send_error_message(tmp_pid, uid, uttid, error, (char*)msg))
+                       SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsdc_send_error_message()");
+       }
 
        if (0 != ttsd_data_set_client_state(uid, APP_STATE_READY))
                SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_data_set_client_state()");
 
-       if (0 != ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY))
-               SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsdc_send_set_state_message()");
-
+       if (tmp_pid > 0) {
+               if (0 != ttsdc_send_set_state_message(tmp_pid, uid, APP_STATE_READY))
+                       SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsdc_send_set_state_message()");
+       }
        return 0;
 }