From: Aida JonikienÄ— <aidas957(a)gmail.com> GTA San Andreas calls these functions with NaN positions under certain circumstances which eventually results in dwTotalAmpFactor value being really high (and causing extremely loud audio output). --- dlls/dsound/sound3d.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c index 3fa9ff6801f..e9c69ae7193 100644 --- a/dlls/dsound/sound3d.c +++ b/dlls/dsound/sound3d.c @@ -703,6 +703,9 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetPosition(IDirectSound3DBuffer TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply); + if (isnan(x) || isnan(y) || isnan(z)) + return DSERR_INVALIDPARAM; + AcquireSRWLockExclusive(&This->lock); This->ds3db_ds3db.vPosition.x = x; @@ -961,6 +964,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(IDirectSound3DLi TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %ld\n", xFront, yFront, zFront, xTop, yTop, zTop, dwApply); + + if (isnan(xFront) || isnan(yFront) || isnan(zFront) + || isnan(xTop) || isnan(yTop) || isnan(zTop)) + return DSERR_INVALIDPARAM; + This->device->ds3dl.vOrientFront.x = xFront; This->device->ds3dl.vOrientFront.y = yFront; This->device->ds3dl.vOrientFront.z = zFront; @@ -982,6 +990,10 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(IDirectSound3DListe IDirectSoundBufferImpl *This = impl_from_IDirectSound3DListener(iface); TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply); + + if (isnan(x) || isnan(y) || isnan(z)) + return DSERR_INVALIDPARAM; + This->device->ds3dl.vPosition.x = x; This->device->ds3dl.vPosition.y = y; This->device->ds3dl.vPosition.z = z; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/6289