From 14db70036d37285fb751f829b609e2e74b56ba66 Mon Sep 17 00:00:00 2001 From: Jeff Zaroyko Date: Fri, 2 Jan 2009 17:03:00 +1100 Subject: [PATCH] dsound: Check for invalid parameter when unlocking primary buffers. --- dlls/dsound/primary.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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;