Fix defects detected by static analysis tool 69/306269/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 19 Feb 2024 07:55:57 +0000 (16:55 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 19 Feb 2024 08:00:20 +0000 (17:00 +0900)
Change-Id: I1782a8acc3e7e4dbdebaa2fd314aec56233592bf

src/service_ipc_dbus.cpp
wakeup-manager/src/wakeup_audio_manager.cpp

index 0e30c72..fa51a91 100644 (file)
@@ -1364,7 +1364,6 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                num_messages++;
        }
 
-       print_duration(num_messages, started);
        return ECORE_CALLBACK_RENEW;
 }
 
index 0d6bb19..991a054 100644 (file)
@@ -340,9 +340,19 @@ void CAudioManager::streaming_audio_data_thread_func(long long start_time)
 
                lock.lock();
                end = mAudioData.end();
+
+               /* Check if the lead variable is still valid, just in case the mAudioData variable
+                * got cleared by another thread before the lock gets acquired again. */
+               bool is_lead_valid = false;
+               for (auto it = mAudioData.begin();is_lead_valid == false && it != end;++it) {
+                       if (lead == it) {
+                               is_lead_valid = true;
+                       }
+               }
+
                vector<IAudioEventObserver*> observers = mObservers;
 
-               if (lead != end) {
+               if (is_lead_valid && lead != end) {
                        iter = lead;
 
                        mas_speech_data speech_data = iter->data;