[AD] bug in wdsound.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


There is a small bug in src/win/wdsound.c, line 485. The variable prim_buf is 
passed to directx without checking if it is NULL first, which leads to a 
segfault.

I've attached a patch that move the call inside the "if (prim_buf) { ... }" 
block a few lines upper, and seems to fix the bug.

-- 
Julien Cugnière
--- wdsound.c.old	Tue Jul 15 17:32:36 2003
+++ wdsound.c	Tue Jul 15 17:33:42 2003
@@ -457,6 +457,9 @@
             format.nBlockAlign, format.wBitsPerSample, format.cbSize);
          }
       }
+
+      /* get primary buffer (global) volume */
+      IDirectSoundBuffer_GetVolume(prim_buf, &initial_volume); 
    }
 
    /* initialize physical voices */
@@ -480,9 +483,6 @@
    alleg_to_dsound_pan[255] = DSBPAN_RIGHT;
    for (v = 128; v < 255; v++)
       alleg_to_dsound_pan[v] = MIN(DSBPAN_RIGHT, DSBPAN_CENTER - 2000.0*log10((255.0-v)/127.0));
-
-   /* get primary buffer (global) volume */
-   IDirectSoundBuffer_GetVolume(prim_buf, &initial_volume); 
 
    return 0;
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/