From 9bc545451b3ef2015a24532a0ad2605d738739a0 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Fri, 14 Jan 2022 10:04:11 -0600 Subject: [PATCH] winecoreaudio.drv: Fix memory leak. Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winecoreaudio.drv/coreaudio.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index 3f694b95a49..a2bbc3e45c9 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -709,6 +709,7 @@ static NTSTATUS release_stream( void *args ) { struct release_stream_params *params = args; struct coreaudio_stream *stream = params->stream; + SIZE_T size; if(stream->unit){ AudioOutputUnitStop(stream->unit); @@ -719,12 +720,16 @@ static NTSTATUS release_stream( void *args ) free(stream->resamp_buffer); free(stream->wrap_buffer); free(stream->cap_buffer); - if(stream->local_buffer) + if(stream->local_buffer){ + size = 0; NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, - &stream->local_buffer_size, MEM_RELEASE); - if(stream->tmp_buffer) + &size, MEM_RELEASE); + } + if(stream->tmp_buffer){ + size = 0; NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, - &stream->tmp_buffer_size, MEM_RELEASE); + &size, MEM_RELEASE); + } free(stream->fmt); free(stream); params->result = S_OK; @@ -1354,8 +1359,9 @@ static NTSTATUS get_render_buffer(void *args) if(stream->wri_offs_frames + params->frames > stream->bufsize_frames){ if(stream->tmp_buffer_frames < params->frames){ if(stream->tmp_buffer){ + SIZE_T size = 0; NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, - &stream->tmp_buffer_size, MEM_RELEASE); + &size, MEM_RELEASE); stream->tmp_buffer = NULL; } stream->tmp_buffer_size = params->frames * stream->fmt->nBlockAlign;