Avoid crash when pid is nagative value
[platform/core/uifw/tts.git] / 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;
 }