wine-staging/patches/06-winepulse/0024-winepulse-v23-fixup-a-invalid-free-in-mmdevapi.patch

52 lines
1.7 KiB
Diff
Raw Normal View History

From 46f5df733fba376a7d6bbb3804fb25e108b760f0 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Tue, 24 Jun 2014 08:48:48 +0200
Subject: [PATCH 31/43] winepulse v23: fixup a invalid free in mmdevapi
array members of ids should be dynamically allocated, judging from valgrind output.
---
dlls/winepulse.drv/mmdevdrv.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 3ca68fd..5b041a2 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -726,6 +726,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **
UINT *num, UINT *def_index)
{
HRESULT hr = S_OK;
+ WCHAR *id;
+
TRACE("%d %p %p %p\n", flow, ids, num, def_index);
pthread_mutex_lock(&pulse_lock);
@@ -737,16 +739,22 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **
*def_index = 0;
*ids = HeapAlloc(GetProcessHeap(), 0, sizeof(**ids));
+ *keys = NULL;
if (!*ids)
return E_OUTOFMEMORY;
- (*ids)[0] = defaultW;
+ (*ids)[0] = id = HeapAlloc(GetProcessHeap(), 0, sizeof(defaultW));
*keys = HeapAlloc(GetProcessHeap(), 0, sizeof(**keys));
- if (!*keys) {
+ if (!*keys || !id) {
+ HeapFree(GetProcessHeap(), 0, id);
+ HeapFree(GetProcessHeap(), 0, *keys);
HeapFree(GetProcessHeap(), 0, *ids);
*ids = NULL;
+ *keys = NULL;
return E_OUTOFMEMORY;
}
+ memcpy(id, defaultW, sizeof(defaultW));
+
if (flow == eRender)
(*keys)[0] = pulse_render_guid;
else
--
2.0.0