Skip to content

Commit

Permalink
Fix crash in AudioThread::setActive
Browse files Browse the repository at this point in the history
If AudioThread::run() hasn't been called yet, we can dereference a null inputQueue
  • Loading branch information
Eoin Mcloughlin committed Oct 7, 2015
1 parent 2a95d05 commit 0b10a5b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/audio/AudioThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ bool AudioThread::isActive() {
void AudioThread::setActive(bool state) {

AudioThreadInput *dummy;
if (state && !active) {
if (state && !active && inputQueue) {
while (!inputQueue->empty()) { // flush queue
inputQueue->pop(dummy);
if (dummy) {
Expand All @@ -438,10 +438,12 @@ void AudioThread::setActive(bool state) {
deviceController[parameters.deviceId]->bindThread(this);
} else if (!state && active) {
deviceController[parameters.deviceId]->removeThread(this);
while (!inputQueue->empty()) { // flush queue
inputQueue->pop(dummy);
if (dummy) {
dummy->decRefCount();
if(inputQueue) {
while (!inputQueue->empty()) { // flush queue
inputQueue->pop(dummy);
if (dummy) {
dummy->decRefCount();
}
}
}
}
Expand Down

0 comments on commit 0b10a5b

Please sign in to comment.