audio: don't free uninitialized audio_buffer

free(NULL) isn't explicitly forbidden, but isn't exactly good style.
Check the rare case that the audio buffer isn't initialized yet in
closeAudioDevice().  In this case, we also don't have to call
flushAudioBuffer().
This commit is contained in:
Max Kellermann 2008-09-10 11:44:02 +02:00
parent 8d1801c59d
commit 5d0a8ce3af
1 changed files with 6 additions and 5 deletions

View File

@ -386,11 +386,12 @@ void closeAudioDevice(void)
{
unsigned int i;
flushAudioBuffer();
free(audio_buffer.buffer);
audio_buffer.buffer = NULL;
audio_buffer.size = 0;
if (audio_buffer.buffer != NULL) {
flushAudioBuffer();
free(audio_buffer.buffer);
audio_buffer.buffer = NULL;
audio_buffer.size = 0;
}
for (i = 0; i < audioOutputArraySize; ++i) {
if (audioDeviceStates[i] == DEVICE_ON)