Commit da29b654 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Make sure the 'alsa handle' is initialized to NULL before calling

snd_pcm_open(). Otherwise if it fails we get a crash trying to close an invalid alsa handle.
parent d6c537b4
...@@ -522,7 +522,7 @@ end: ...@@ -522,7 +522,7 @@ end:
*/ */
LONG ALSA_WaveInit(void) LONG ALSA_WaveInit(void)
{ {
snd_pcm_t* h = NULL; snd_pcm_t* h;
snd_pcm_info_t * info; snd_pcm_info_t * info;
snd_pcm_hw_params_t * hw_params; snd_pcm_hw_params_t * hw_params;
WINE_WAVEOUT* wwo; WINE_WAVEOUT* wwo;
...@@ -555,6 +555,7 @@ LONG ALSA_WaveInit(void) ...@@ -555,6 +555,7 @@ LONG ALSA_WaveInit(void)
#define EXIT_ON_ERROR(f,txt) do { int err; if ( (err = (f) ) < 0) { ERR(txt ": %s\n", snd_strerror(err)); if (h) snd_pcm_close(h); return -1; } } while(0) #define EXIT_ON_ERROR(f,txt) do { int err; if ( (err = (f) ) < 0) { ERR(txt ": %s\n", snd_strerror(err)); if (h) snd_pcm_close(h); return -1; } } while(0)
h = NULL;
ALSA_WodNumDevs = 0; ALSA_WodNumDevs = 0;
EXIT_ON_ERROR( snd_pcm_open(&h, wwo->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) , "open pcm" ); EXIT_ON_ERROR( snd_pcm_open(&h, wwo->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) , "open pcm" );
if (!h) return -1; if (!h) return -1;
...@@ -661,6 +662,7 @@ LONG ALSA_WaveInit(void) ...@@ -661,6 +662,7 @@ LONG ALSA_WaveInit(void)
#define EXIT_ON_ERROR(f,txt) do { int err; if ( (err = (f) ) < 0) { ERR(txt ": %s\n", snd_strerror(err)); if (h) snd_pcm_close(h); return -1; } } while(0) #define EXIT_ON_ERROR(f,txt) do { int err; if ( (err = (f) ) < 0) { ERR(txt ": %s\n", snd_strerror(err)); if (h) snd_pcm_close(h); return -1; } } while(0)
h = NULL;
ALSA_WidNumDevs = 0; ALSA_WidNumDevs = 0;
EXIT_ON_ERROR( snd_pcm_open(&h, wwi->device, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK) , "open pcm" ); EXIT_ON_ERROR( snd_pcm_open(&h, wwi->device, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK) , "open pcm" );
if (!h) return -1; if (!h) return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment