Fix a bug where TestAudioDeviceModule crashes if destroyed uninitialized.
Because thread_ object is created in Init, destructor used to crash when
calling thread_->Stop() because it was referencing a null pointer.
Bug: webrtc:9404
Change-Id: I1c943d0fa50f9341aaa516b32495bb25bf4d664b
Reviewed-on: https://webrtc-review.googlesource.com/84122
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23682}
diff --git a/modules/audio_device/include/test_audio_device.cc b/modules/audio_device/include/test_audio_device.cc
index 9d833b3..e24afda 100644
--- a/modules/audio_device/include/test_audio_device.cc
+++ b/modules/audio_device/include/test_audio_device.cc
@@ -81,7 +81,9 @@
~TestAudioDeviceModuleImpl() {
StopPlayout();
StopRecording();
- thread_->Stop();
+ if (thread_) {
+ thread_->Stop();
+ }
}
int32_t Init() {