Add NULL checking when releasing resources
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 29 Aug 2019 10:06:17 +0000 (19:06 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 29 Aug 2019 10:08:15 +0000 (19:08 +0900)
Change-Id: I3b1b86e33c97a64be602aefdea8a5ca0d9c774b4

plugins/wakeup-manager/dependency-default/src/dependency_default_audio.cpp

index b2c231f..86b2df1 100644 (file)
@@ -214,21 +214,27 @@ void dependency_default_audio_deinitialize()
                g_volume_stream = NULL;
        }
 
-       ret = audio_in_unprepare(g_audio_in);
-       if (AUDIO_IO_ERROR_NONE != ret) {
-               LOGD("[Recorder ERROR] Fail to stop audio : %d", ret);
+       if (g_audio_in) {
+               ret = audio_in_unprepare(g_audio_in);
+               if (AUDIO_IO_ERROR_NONE != ret) {
+                       LOGD("[Recorder ERROR] Fail to stop audio : %d", ret);
+               }
        }
 
-       if (0 != sound_manager_destroy_stream_information(g_stream_info)) {
-               LOGD("[Recorder ERROR] Fail to destroy stream info");
+       if (g_stream_info) {
+               if (0 != sound_manager_destroy_stream_information(g_stream_info)) {
+                       LOGD("[Recorder ERROR] Fail to destroy stream info");
+               }
+               g_stream_info = NULL;
        }
-       g_stream_info = NULL;
 
-       ret = audio_in_destroy(g_audio_in);
-       if (AUDIO_IO_ERROR_NONE != ret) {
-               LOGD("[Recorder ERROR] Fail to destroy audio : %d", ret);
+       if (g_audio_in) {
+               ret = audio_in_destroy(g_audio_in);
+               if (AUDIO_IO_ERROR_NONE != ret) {
+                       LOGD("[Recorder ERROR] Fail to destroy audio : %d", ret);
+               }
+               g_audio_in = NULL;
        }
-       g_audio_in = NULL;
 }
 
 static void recorder_thread_func()