[DSOUND] fix duplex create bug

Robert Reif reif at earthlink.net
Mon Feb 27 06:34:01 CST 2006


Fix duplex create bug found by smatch.
-------------- next part --------------
Index: dlls/dsound/duplex.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/duplex.c,v
retrieving revision 1.6
diff -p -u -r1.6 duplex.c
--- dlls/dsound/duplex.c	17 Jan 2006 15:32:59 -0000	1.6
+++ dlls/dsound/duplex.c	27 Feb 2006 12:29:48 -0000
@@ -258,6 +258,12 @@ HRESULT IDirectSoundFullDuplex_IDirectSo
         return DSERR_INVALIDPARAM;
     }
 
+    if (((IDirectSoundFullDuplexImpl*)pdsfd)->renderer_device == NULL) {
+        WARN("not initialized\n");
+        *ppds = NULL;
+        return DSERR_UNINITIALIZED;
+    }
+
     pdsfdds = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdds));
     if (pdsfdds == NULL) {
         WARN("out of memory\n");
@@ -417,6 +423,12 @@ HRESULT IDirectSoundFullDuplex_IDirectSo
         return DSERR_INVALIDPARAM;
     }
 
+    if (((IDirectSoundFullDuplexImpl*)pdsfd)->renderer_device == NULL) {
+        WARN("not initialized\n");
+        *ppds8 = NULL;
+        return DSERR_UNINITIALIZED;
+    }
+
     pdsfdds8 = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfdds8));
     if (pdsfdds8 == NULL) {
         WARN("out of memory\n");
@@ -525,6 +537,12 @@ HRESULT IDirectSoundFullDuplex_IDirectSo
         return DSERR_INVALIDPARAM;
     }
 
+    if (((IDirectSoundFullDuplexImpl*)pdsfd)->capture_device == NULL) {
+        WARN("not initialized\n");
+        *ppdsc8 = NULL;
+        return DSERR_UNINITIALIZED;
+    }
+
     pdsfddsc = HeapAlloc(GetProcessHeap(),0,sizeof(*pdsfddsc));
     if (pdsfddsc == NULL) {
         WARN("out of memory\n");
@@ -774,6 +792,8 @@ HRESULT DSOUND_FullDuplexCreate(LPDIRECT
     This->capture_device = NULL;
     This->renderer_device = NULL;
 
+    *ppDSFD = (LPDIRECTSOUNDFULLDUPLEX)This;
+
     return DS_OK;
 }
 


More information about the wine-patches mailing list