diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 5812f0086f0..f0ba854d9f2 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -999,8 +999,12 @@ static HRESULT WINAPI PrimaryBufferImpl_Unlock( if (!(device->drvdesc.dwFlags & DSDDESC_DONTNEEDPRIMARYLOCK) && device->hwbuf) { HRESULT hres; - - hres = IDsDriverBuffer_Unlock(device->hwbuf, p1, x1, p2, x2); + + if ((char *)p1 - (char *)device->buffer + x1 > device->buflen) + hres = DSERR_INVALIDPARAM; + else + hres = IDsDriverBuffer_Unlock(device->hwbuf, p1, x1, p2, x2); + if (hres != DS_OK) { WARN("IDsDriverBuffer_Unlock failed\n"); return hres;