From 61ab63a4be73b5a70a26604e05c2bdea669ceca6 Mon Sep 17 00:00:00 2001 From: Mark Riedesel Date: Mon, 18 Oct 2021 09:52:01 -0400 Subject: [PATCH] fix potential memory leak of AudioStreamPlaybackBusDetails in AudioServer::start_playback_stream() --- servers/audio_server.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index a420134626f..ab704c6f785 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -1131,8 +1131,10 @@ void AudioServer::start_playback_stream(Ref p_playback, Map AudioStreamPlaybackBusDetails *new_bus_details = new AudioStreamPlaybackBusDetails(); int idx = 0; for (KeyValue> pair : p_bus_volumes) { - ERR_FAIL_COND(pair.value.size() < channel_count); - ERR_FAIL_COND(pair.value.size() != MAX_CHANNELS_PER_BUS); + if (pair.value.size() < channel_count || pair.value.size() != MAX_CHANNELS_PER_BUS) { + delete new_bus_details; + ERR_FAIL(); + } new_bus_details->bus_active[idx] = true; new_bus_details->bus[idx] = pair.key;