[PATCH v2] dsound: Make GlobalHandle() for the sound buffer failed.
Andrew Eikum
aeikum at codeweavers.com
Fri Feb 28 09:22:32 CST 2020
On Wed, Feb 26, 2020 at 09:43:03PM +0900, Akihiro Sagawa wrote:
> In v2, remove an unreliable conformance test. It crashes on x64 Windows.
>
Would it be possible to add the test for 32-bit only? Without a test I
worry we could lose this change in a future patch.
> diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
> index 8d4a3b9..b019b0d 100644
> --- a/dlls/dsound/buffer.c
> +++ b/dlls/dsound/buffer.c
> @@ -1054,19 +1054,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)));
> + dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)) + 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;
> - }
> + /* Assign subsequent memory for buffer
> + to make GlobalHandle(dsb->buffer->memory) call fail */
> + dsb->buffer->memory = (LPBYTE)dsb->buffer + sizeof(*(dsb->buffer));
>
I think we need to make sure memory is aligned -- e.g. round up the
size of dst->buffer to nearest alignment. Or, some other solution
might be more elegant; Zeb suggested VirtualAlloc might solve this?
Andrew
More information about the wine-devel
mailing list