aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-10 11:44:02 +0200
committerMax Kellermann <max@duempel.org>2008-09-10 11:44:02 +0200
commit5d0a8ce3af943c33c4287907033c6ad0a335fba6 (patch)
treed537a697626f8d766aea922b9fd18259a2ab6c24 /src/audio.c
parent8d1801c59d67617541447a47b7fdd2cbcb4bc7cb (diff)
downloadmpd-5d0a8ce3af943c33c4287907033c6ad0a335fba6.tar.gz
mpd-5d0a8ce3af943c33c4287907033c6ad0a335fba6.tar.xz
mpd-5d0a8ce3af943c33c4287907033c6ad0a335fba6.zip
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().
Diffstat (limited to 'src/audio.c')
-rw-r--r--src/audio.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/audio.c b/src/audio.c
index b868edb30..7c430b326 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -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)