Fix DSOUND_Create() crash

Francois Gouget fgouget at codeweavers.com
Mon Aug 2 11:18:20 CDT 2004


Robert's last change caused DSOUND_Create() to crash because it relied 
on *ppDS to be set to NULL on errors and did not check the return code 
of IDirectSoundImpl_Create().

So I fixed IDirectSoundImpl_Create() to set ppDS to NULL in case of an 
error but it still seems more correct to check its return value to 
detect errors, especially as DSOUND_Create() then returns this as the 
return code.


Changelog:

  * dlls/dsound/dsound.c

    Francois Gouget <fgouget at codeweavers.com>
    Check the return value of IDirectSoundImpl_Create() to detect errors.
    Always set *ppDS to NULL in cas of error.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/dsound/dsound.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/dsound.c,v
retrieving revision 1.9
diff -u -r1.9 dsound.c
--- dlls/dsound/dsound.c	30 Jul 2004 18:42:23 -0000	1.9
+++ dlls/dsound/dsound.c	2 Aug 2004 15:39:39 -0000
@@ -757,6 +757,7 @@
 
     if (found == FALSE) {
         WARN("No device found matching given ID!\n");
+        *ppDS = NULL;
         return DSERR_NODRIVER;
     }
 
@@ -1641,7 +1642,7 @@
     } else {
         LPDIRECTSOUND8 pDS;
         hr = IDirectSoundImpl_Create(&devGuid, &pDS);
-        if (pDS) {
+        if (hr == DS_OK) {
             hr = DSOUND_PrimaryCreate((IDirectSoundImpl*)pDS);
             if (hr == DS_OK) {
                 hr = IDirectSound_IDirectSound_Create(pDS, ppDS);
@@ -1746,7 +1747,7 @@
     } else {
         LPDIRECTSOUND8 pDS;
         hr = IDirectSoundImpl_Create(&devGuid, &pDS);
-        if (pDS) {
+        if (hr == DS_OK) {
             hr = DSOUND_PrimaryCreate((IDirectSoundImpl*)pDS);
             if (hr == DS_OK) {
                 hr = IDirectSound8_IDirectSound8_Create(pDS, ppDS);


More information about the wine-patches mailing list