Akihiro Sagawa : dsound: Make GlobalHandle() for the sound buffer failed.
Alexandre Julliard
julliard at winehq.org
Tue Jun 2 08:11:17 CDT 2020
Module: wine
Branch: stable
Commit: 0a0bdbf1dc1d38fa7a5f42bcd563eb46f2291918
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0a0bdbf1dc1d38fa7a5f42bcd563eb46f2291918
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Fri Mar 6 21:52:46 2020 +0900
dsound: Make GlobalHandle() for the sound buffer failed.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 70aeb7e4b0eb8efefd24c26d1c1442ea6c25d082)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/dsound/buffer.c | 15 +++++----------
dlls/dsound/tests/dsound.c | 2 +-
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index f600652914..1a3e3b9526 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -1014,6 +1014,7 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
LPWAVEFORMATEX wfex = dsbd->lpwfxFormat;
HRESULT err = DS_OK;
DWORD capf = 0;
+ size_t bufsize;
TRACE("(%p,%p,%p)\n", device, dsbd, buffer);
@@ -1069,19 +1070,15 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
TRACE("capf = 0x%08x, device->drvcaps.dwFlags = 0x%08x\n", capf, device->drvcaps.dwFlags);
/* Allocate an empty buffer */
- dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)));
+ bufsize = (sizeof(*(dsb->buffer)) + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
+ dsb->buffer = HeapAlloc(GetProcessHeap(),0,bufsize + dsb->buflen);
if (!dsb->buffer) {
IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface);
return DSERR_OUTOFMEMORY;
}
/* Allocate system memory for buffer */
- dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
- if (!dsb->buffer->memory) {
- WARN("out of memory\n");
- IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface);
- return DSERR_OUTOFMEMORY;
- }
+ dsb->buffer->memory = (BYTE *)dsb->buffer + bufsize;
dsb->buffer->ref = 1;
dsb->buffer->lockedbytes = 0;
@@ -1152,10 +1149,8 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
This->buffer->ref--;
list_remove(&This->entry);
- if (This->buffer->ref == 0) {
- HeapFree(GetProcessHeap(), 0, This->buffer->memory);
+ if (This->buffer->ref == 0)
HeapFree(GetProcessHeap(), 0, This->buffer);
- }
HeapFree(GetProcessHeap(), 0, This->notifies);
HeapFree(GetProcessHeap(), 0, This->pwfx);
diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
index 0e779618a2..2bf87eb857 100644
--- a/dlls/dsound/tests/dsound.c
+++ b/dlls/dsound/tests/dsound.c
@@ -1161,7 +1161,7 @@ static HRESULT test_duplicate(LPGUID lpGuid)
/* broken apps like Asuka 120% Return BURNING Fest,
pass the pointer to GlobalHandle. */
HGLOBAL hmem = GlobalHandle(buf);
- todo_wine ok(!hmem,"GlobalHandle should return NULL "
+ ok(!hmem,"GlobalHandle should return NULL "
"for buffer %p, got %p\n",buf,hmem);
}
ZeroMemory(buf,bufsize);
More information about the wine-cvs
mailing list