[PATCH 0/1] MR3847: winmm: Handle memory allocation failure in WINMM_OpenDevice (cppcheck).
From: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/winmm/waveform.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c index 8c0cc4d879c..ea86548a44a 100644 --- a/dlls/winmm/waveform.c +++ b/dlls/winmm/waveform.c @@ -1064,6 +1064,7 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info, { LRESULT ret = MMSYSERR_NOMEM; HRESULT hr; + void *mem; hr = IMMDeviceEnumerator_GetDevice(g_devenum, device->parent->dev_id, &device->device); @@ -1165,10 +1166,12 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_OpenInfo *info, /* As the devices thread is waiting on g_device_handles, it can * only be modified from within this same thread. */ - g_device_handles = realloc(g_device_handles, - sizeof(HANDLE) * (g_devhandle_count + 1)); - g_handle_devices = realloc(g_handle_devices, - sizeof(WINMM_Device *) * (g_devhandle_count + 1)); + mem = realloc(g_device_handles, sizeof(HANDLE) * (g_devhandle_count + 1)); + if (!mem) goto error; + g_device_handles = mem; + mem = realloc(g_handle_devices, sizeof(WINMM_Device *) * (g_devhandle_count + 1)); + if (!mem) goto error; + g_handle_devices = mem; g_device_handles[g_devhandle_count] = device->event; g_handle_devices[g_devhandle_count] = device; ++g_devhandle_count; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3847
This merge request was approved by Huw Davies. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3847
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Huw Davies (@huw)