Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc56e476 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Fix crash in audiosystem_tests

Add nullptr check to AudioSystemTest::TearDown to handle
cases when initialization did not complete successfully.

Bug: 205884982
Test: atest audiosystem_tests
Change-Id: Id1e8ca4b9312af621ab200bd8217da6159d1cfc9
parent 6fa1c89b
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -49,12 +49,18 @@ class AudioSystemTest : public ::testing::Test {
    void TearDown() override {
        if (mPlayback) {
            mPlayback->stop();
            mPlayback->getAudioTrackHandle()->removeAudioDeviceCallback(mCbPlayback);
            if (auto handle = mPlayback->getAudioTrackHandle(); handle) {
                handle->removeAudioDeviceCallback(mCbPlayback);
            }
            mCbPlayback.clear();
            mPlayback.clear();
        }
        if (mCapture) {
            mCapture->stop();
            mCapture->getAudioRecordHandle()->removeAudioDeviceCallback(mCbRecord);
            if (auto handle = mCapture->getAudioRecordHandle(); handle) {
                handle->removeAudioDeviceCallback(mCbRecord);
            }
            mCbRecord.clear();
            mCapture.clear();
        }
    }