Fix a memory leak in ma_sound_init_copy().

Public issue https://github.com/mackron/miniaudio/issues/667
This commit is contained in:
David Reid
2023-05-03 08:02:42 +10:00
parent 4326fad97a
commit ae25dbcdac
+4 -1
View File
@@ -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) 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); pSound->pResourceManagerDataSource = (ma_resource_manager_data_source*)ma_malloc(sizeof(*pSound->pResourceManagerDataSource), &pEngine->allocationCallbacks);
if (pSound->pResourceManagerDataSource == NULL) { 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; 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; return MA_SUCCESS;
} }
#endif #endif