From ae25dbcdacdaf971da521b9a08cee1b60edb613a Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 3 May 2023 08:02:42 +1000 Subject: [PATCH] Fix a memory leak in ma_sound_init_copy(). Public issue https://github.com/mackron/miniaudio/issues/667 --- miniaudio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/miniaudio.h b/miniaudio.h index dbe8e4d1..9bf8555a 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -75444,7 +75444,7 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin /* We need to make a clone of the data source. If the data source is not a data buffer (i.e. a stream) - the this will fail. + this will fail. */ pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks); if (pSound->pResourceManagerDataSource == NULL) { @@ -75472,6 +75472,9 @@ MA_API ma_result ma_sound_init_copy(ma_engine* pEngine, const ma_sound* pExistin return result; } + /* Make sure the sound is marked as the owner of the data source or else it will never get uninitialized. */ + pSound->ownsDataSource = MA_TRUE; + return MA_SUCCESS; } #endif