Commit 9eb9a10e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

DirectSound: fix double free on error (close #5966)

Regression from 6d90bf20
parent f09289e8
...@@ -92,7 +92,6 @@ struct aout_sys_t ...@@ -92,7 +92,6 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
static int OpenAudio ( vlc_object_t * ); static int OpenAudio ( vlc_object_t * );
static void CloseAudio ( vlc_object_t * ); static void CloseAudio ( vlc_object_t * );
static void CloseAudioCommon ( vlc_object_t * );
static void Play ( audio_output_t *, block_t * ); static void Play ( audio_output_t *, block_t * );
/* local functions */ /* local functions */
...@@ -278,8 +277,7 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -278,8 +277,7 @@ static int OpenAudio( vlc_object_t *p_this )
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
msg_Err( p_aout, "cannot open directx audio device" ); msg_Err( p_aout, "cannot open directx audio device" );
free( p_aout->sys ); goto error;
return VLC_EGENERIC;
} }
/* Calculate the frame size in bytes */ /* Calculate the frame size in bytes */
...@@ -303,8 +301,8 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -303,8 +301,8 @@ static int OpenAudio( vlc_object_t *p_this )
msg_Err( p_aout, "cannot create DirectSoundThread" ); msg_Err( p_aout, "cannot create DirectSoundThread" );
CloseHandle( p_aout->sys->notif.event ); CloseHandle( p_aout->sys->notif.event );
p_aout->sys->notif.event = NULL; p_aout->sys->notif.event = NULL;
CloseAudio( VLC_OBJECT(p_aout) ); aout_PacketDestroy( p_aout );
return VLC_EGENERIC; goto error;
} }
p_aout->pf_play = Play; p_aout->pf_play = Play;
...@@ -314,7 +312,7 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -314,7 +312,7 @@ static int OpenAudio( vlc_object_t *p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
CloseAudioCommon( VLC_OBJECT(p_aout) ); CloseAudio( VLC_OBJECT(p_aout) );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -576,13 +574,6 @@ static void Play( audio_output_t *p_aout, block_t *p_buffer ) ...@@ -576,13 +574,6 @@ static void Play( audio_output_t *p_aout, block_t *p_buffer )
* CloseAudio: close the audio device * CloseAudio: close the audio device
*****************************************************************************/ *****************************************************************************/
static void CloseAudio( vlc_object_t *p_this ) static void CloseAudio( vlc_object_t *p_this )
{
audio_output_t * p_aout = (audio_output_t *)p_this;
aout_PacketDestroy( p_aout );
CloseAudioCommon( p_this );
}
static void CloseAudioCommon( vlc_object_t *p_this )
{ {
audio_output_t * p_aout = (audio_output_t *)p_this; audio_output_t * p_aout = (audio_output_t *)p_this;
aout_sys_t *p_sys = p_aout->sys; aout_sys_t *p_sys = p_aout->sys;
...@@ -599,6 +590,7 @@ static void CloseAudioCommon( vlc_object_t *p_this ) ...@@ -599,6 +590,7 @@ static void CloseAudioCommon( vlc_object_t *p_this )
vlc_join( p_sys->notif.thread, NULL ); vlc_join( p_sys->notif.thread, NULL );
CloseHandle( p_sys->notif.event ); CloseHandle( p_sys->notif.event );
aout_PacketDestroy( p_aout );
} }
/* release the secondary buffer */ /* release the secondary buffer */
...@@ -610,8 +602,6 @@ static void CloseAudioCommon( vlc_object_t *p_this ) ...@@ -610,8 +602,6 @@ static void CloseAudioCommon( vlc_object_t *p_this )
/* free DSOUND.DLL */ /* free DSOUND.DLL */
if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll ); if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll );
aout_PacketDestroy( p_aout );
free( p_aout->sys->p_device_guid ); free( p_aout->sys->p_device_guid );
free( p_sys ); free( p_sys );
} }
......
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