From 821e5dec25df705cae8cec1532daea238be91af7 Mon Sep 17 00:00:00 2001 From: Jeff Zaroyko Date: Fri, 2 Jan 2009 17:39:10 +1100 Subject: dsound: check for invalid parameter when locking primary and secondary buffers --- dlls/dsound/buffer.c | 3 +++ dlls/dsound/primary.c | 3 +++ dlls/dsound/tests/ds3d.c | 4 ++++ 3 files changed, 10 insertions(+), 0 deletions(-) diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c index 6659a47..038a90e 100644 --- a/dlls/dsound/buffer.c +++ b/dlls/dsound/buffer.c @@ -532,6 +532,9 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock( GetTickCount() ); + if (!audiobytes1) + return DSERR_INVALIDPARAM; + /* when this flag is set, writecursor is meaningless and must be calculated */ if (flags & DSBLOCK_FROMWRITECURSOR) { /* GetCurrentPosition does too much magic to duplicate here */ diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 5812f00..7146ae8 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -837,6 +837,9 @@ static HRESULT WINAPI PrimaryBufferImpl_Lock( GetTickCount() ); + if (!audiobytes1) + return DSERR_INVALIDPARAM; + if (device->priolevel != DSSCL_WRITEPRIMARY) { WARN("failed priority check!\n"); return DSERR_PRIOLEVELNEEDED; diff --git a/dlls/dsound/tests/ds3d.c b/dlls/dsound/tests/ds3d.c index c3fa0ed..db662c0 100644 --- a/dlls/dsound/tests/ds3d.c +++ b/dlls/dsound/tests/ds3d.c @@ -184,6 +184,10 @@ static int buffer_refill(play_state_t* state, DWORD size) if (size>state->wave_len-state->written) size=state->wave_len-state->written; + /* some broken apps like Navyfield mistakenly pass NULL for a ppValue */ + rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size, + &ptr1,NULL,&ptr2,&len2,0); + ok(rc==DSERR_INVALIDPARAM,"expected %08x got %08x\n",DSERR_INVALIDPARAM, rc); rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size, &ptr1,&len1,&ptr2,&len2,0); ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %08x\n", rc); -- 1.5.4.3