Resource Manager: Fix a possible crash when loading fails.

Public issue: https://github.com/mackron/miniaudio/issues/1129
This commit is contained in:
David Reid
2026-07-13 08:39:19 +10:00
parent cca9aaab77
commit 87206fca67
2 changed files with 20 additions and 14 deletions
+1
View File
@@ -4,6 +4,7 @@ v0.11.26 - TBD
* Fixed a crash when passing in null for the read or seek callbacks for a decoder. * Fixed a crash when passing in null for the read or seek callbacks for a decoder.
* Fixed an error with node initialization. * Fixed an error with node initialization.
* Fixed build for Arm64EC on MSVC. * Fixed build for Arm64EC on MSVC.
* Resource Manager: Fixed a possible crash when loading fails.
* PulseAudio: Improvements to format negotiation to better handle cases when PulseAudio reports s24_32 as its native format. * PulseAudio: Improvements to format negotiation to better handle cases when PulseAudio reports s24_32 as its native format.
* Emscripten: Fixed an error with ALLOW_MEMORY_GROWTH. * Emscripten: Fixed an error with ALLOW_MEMORY_GROWTH.
* Emscripten: Fixed some issues relating to handling of 64-bit pointers. * Emscripten: Fixed some issues relating to handling of 64-bit pointers.
+6 -1
View File
@@ -71042,11 +71042,15 @@ static ma_result ma_resource_manager_data_buffer_node_acquire(ma_resource_manage
} }
done: done:
{
ma_bool32 isDataOwnedByResourceManager = pDataBufferNode->isDataOwnedByResourceManager;
/* If we failed to initialize the data buffer we need to free it. */ /* If we failed to initialize the data buffer we need to free it. */
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
if (nodeAlreadyExists == MA_FALSE) { if (nodeAlreadyExists == MA_FALSE) {
ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode); ma_resource_manager_data_buffer_node_remove(pResourceManager, pDataBufferNode);
ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks); ma_free(pDataBufferNode, &pResourceManager->config.allocationCallbacks);
pDataBufferNode = NULL;
} }
} }
@@ -71054,11 +71058,12 @@ done:
The init notification needs to be uninitialized. This will be used if the node does not already The init notification needs to be uninitialized. This will be used if the node does not already
exist, and we've specified ASYNC | WAIT_INIT. exist, and we've specified ASYNC | WAIT_INIT.
*/ */
if (nodeAlreadyExists == MA_FALSE && pDataBufferNode->isDataOwnedByResourceManager && (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) != 0) { if (nodeAlreadyExists == MA_FALSE && isDataOwnedByResourceManager && (flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC) != 0) {
if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) { if ((flags & MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT) != 0) {
ma_resource_manager_inline_notification_uninit(&initNotification); ma_resource_manager_inline_notification_uninit(&initNotification);
} }
} }
}
if (ppDataBufferNode != NULL) { if (ppDataBufferNode != NULL) {
*ppDataBufferNode = pDataBufferNode; *ppDataBufferNode = pDataBufferNode;