Jeff Zaroyko : dsound: Check for invalid parameter when locking primary and secondary buffers.

Alexandre Julliard julliard at winehq.org
Fri Jan 2 08:25:50 CST 2009


Module: wine
Branch: master
Commit: aff1dbe5316db08d7c71ebbde0d3894b5630e428
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=aff1dbe5316db08d7c71ebbde0d3894b5630e428

Author: Jeff Zaroyko <jeffz at jeffz.name>
Date:   Fri Jan  2 17:39:10 2009 +1100

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 f0ba854..288466a 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);




More information about the wine-cvs mailing list