From 51059e935c96010964cbf94d571e7e32c4467041 Mon Sep 17 00:00:00 2001 From: Charles Steinkuehler Date: Mon, 8 Nov 2021 23:55:11 +0000 Subject: [PATCH 1/2] Fix use of uninitialized variables When shutting down, the resultALSA variable can be used when uninitialized in the ma_device_read__alsa and ma_device_write__alsa routines. This has been verified by both gcc warnings and in application code (we were occasionally seeing segfaults when our callback routine was being passed a crazy large value for the number of frames read when shutting down). Signed-off-by: Charles Steinkuehler --- miniaudio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 5793f20d..728ba89a 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -21213,7 +21213,7 @@ static ma_result ma_device_wait_write__alsa(ma_device* pDevice) static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead) { - ma_snd_pcm_sframes_t resultALSA; + ma_snd_pcm_sframes_t resultALSA = 0; MA_ASSERT(pDevice != NULL); MA_ASSERT(pFramesOut != NULL); @@ -21267,7 +21267,7 @@ static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_u static ma_result ma_device_write__alsa(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten) { - ma_snd_pcm_sframes_t resultALSA; + ma_snd_pcm_sframes_t resultALSA = 0; MA_ASSERT(pDevice != NULL); MA_ASSERT(pFrames != NULL); From 45622bd77758be21a2e26b09f9a044b623e97dec Mon Sep 17 00:00:00 2001 From: David Reid Date: Sun, 14 Nov 2021 17:34:20 +1000 Subject: [PATCH 2/2] Update revision history. --- miniaudio.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 728ba89a..b5ae38f6 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -1,6 +1,6 @@ /* Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. -miniaudio - v0.10.42 - 2021-08-22 +miniaudio - v0.10.43 - TBD David Reid - mackron@gmail.com @@ -1498,7 +1498,7 @@ extern "C" { #define MA_VERSION_MAJOR 0 #define MA_VERSION_MINOR 10 -#define MA_VERSION_REVISION 42 +#define MA_VERSION_REVISION 43 #define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION) #if defined(_MSC_VER) && !defined(__clang__) @@ -69439,6 +69439,9 @@ The following miscellaneous changes have also been made. /* REVISION HISTORY ================ +v0.10.43 - TBD + - ALSA: Fix use of uninitialized variables + v0.10.42 - 2021-08-22 - Fix a possible deadlock when stopping devices.