Module: wine Branch: master Commit: 70aeb7e4b0eb8efefd24c26d1c1442ea6c25d082 URL: https://source.winehq.org/git/wine.git/?a=commit;h=70aeb7e4b0eb8efefd24c26d1...
Author: Akihiro Sagawa sagawa.aki@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@gmail.com Signed-off-by: Andrew Eikum aeikum@codeweavers.com Signed-off-by: Alexandre Julliard julliard@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 8d4a3b92fa..ea428c0816 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -999,6 +999,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);
@@ -1054,19 +1055,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; @@ -1136,10 +1133,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);