From b7159b76d5f2f30198fa7baf1d67ea28d7aa7bbe Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 3 Dec 2022 11:07:34 +1000 Subject: [PATCH] Update ma_noise_set_type() to prevent a crash. Updating the noise type should not be supported. An oversight on my part. Users should reinitialize a fresh `ma_noise` object instead. This change simply returns an error and triggers an assert in debug mode. Public issue: https://github.com/mackron/miniaudio/issues/585 --- miniaudio.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 7558fcbf..261b79d9 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -65046,8 +65046,14 @@ MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type) return MA_INVALID_ARGS; } - pNoise->config.type = type; - return MA_SUCCESS; + /* + This function should never have been implemented in the first place. Changing the type dynamically is not + supported. Instead you need to uninitialize and reinitiailize a fresh `ma_noise` object. This function + will be removed in version 0.12. + */ + MA_ASSERT(MA_FALSE); + + return MA_INVALID_OPERATION; } static MA_INLINE float ma_noise_f32_white(ma_noise* pNoise)