[SVACE] Add to check NULL value of `tw_get_instance()` 43/317643/1 accepted/tizen_9.0_unified accepted/tizen/9.0/unified/20250107.160055
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 6 Jan 2025 03:03:27 +0000 (12:03 +0900)
committerYoungsun Suh <youngsun.suh@samsung.com>
Mon, 6 Jan 2025 07:55:46 +0000 (07:55 +0000)
Change-Id: I92902010db993749d14556dacabc9577791d55dd
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
(cherry picked from commit 965401e0191e8269407167d86c3d64c3862fb778)

src/screen_reader_tts.c

index ed6687e7d65b3d4518719efb8a6ee6bdd6aba5ca..67b1abec1eb16b42dcb6756cac3a837d2476335d 100644 (file)
@@ -173,12 +173,14 @@ void tw_set_utterance_cb(
                utterance_cb_t deleter)
 {
        TWData *tw = tw_get_instance();
-       if (tw->on_utterance_end_user_data && tw->on_utterance_end_deleter)
-               tw->on_utterance_end_deleter(tw->on_utterance_end_user_data);
+       if (tw) {
+               if (tw->on_utterance_end_user_data && tw->on_utterance_end_deleter)
+                       tw->on_utterance_end_deleter(tw->on_utterance_end_user_data);
 
-       tw->on_utterance_end = uter_cb;
-       tw->on_utterance_end_user_data = user_data;
-       tw->on_utterance_end_deleter = deleter;
+               tw->on_utterance_end = uter_cb;
+               tw->on_utterance_end_user_data = user_data;
+               tw->on_utterance_end_deleter = deleter;
+       }
 }
 
 static Eina_Bool _do_atspi_action_by_name(AtspiAccessible *obj, const char *name)
@@ -565,6 +567,8 @@ static bool have_read_command(TWData *tw)
 static Eina_Bool tw_speak_delay_finished_cb(void *d)
 {
        TWData *tw = tw_get_instance();
+       if (!tw)
+               return EINA_FALSE;
 
        tw->delay_timer = NULL;
        if (tw->last_read_command == d)
@@ -713,6 +717,8 @@ tw_speak_customized(const char *text_to_speak, Eina_Bool want_discard_previous_r
                                         Eina_Bool discardable, AtspiAccessible *obj, unsigned int delay)
 {
        TWData *tw = tw_get_instance();
+       if (!tw)
+               return EINA_FALSE;
 
        if (text_to_speak == NULL) return NULL;