From fd5ce687b3f4b8bc7ba938dd78ea5874d167ce1c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Mar 2018 20:37:39 -0700 Subject: [PATCH] openal: Add cleanup guards to buffer functions Without this, the audio might encounter an error, call cleanup() on itself, and (if in the middle of update()) try to dereference its recently cleaned-up _sd pointer. Fixes #230 --- panda/src/audiotraits/openalAudioSound.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 86fc6e2bef..5922239a00 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -434,6 +434,7 @@ correct_calibrated_clock(double rtc, double t) { void OpenALAudioSound:: pull_used_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); + if (_manager == 0) return; while (_stream_queued.size()) { ALuint buffer = 0; ALint num_buffers = 0; @@ -489,6 +490,8 @@ push_fresh_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); static unsigned char data[65536]; + if (_manager == 0) return; + if (_sd->_sample) { while ((_loops_completed < _playing_loops) && (_stream_queued.size() < 100)) {