From 4ae866a0a7f65a4a4d2c95c5c98145b02d63528e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Sat, 9 Sep 2023 14:51:56 +0200 Subject: [PATCH] dmusic: Stop leaking instruments on collection release. --- dlls/dmusic/collection.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index 0b4e23b34f4..2d4a7f855ae 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -98,7 +98,18 @@ static ULONG WINAPI collection_Release(IDirectMusicCollection *iface) TRACE("(%p): new ref = %lu\n", iface, ref); - if (!ref) { + if (!ref) + { + struct instrument_entry *instrument_entry; + void *next; + + LIST_FOR_EACH_ENTRY_SAFE(instrument_entry, next, &This->instruments, struct instrument_entry, entry) + { + list_remove(&instrument_entry->entry); + IDirectMusicInstrument_Release(instrument_entry->instrument); + free(instrument_entry); + } + free(This); }