[vlc-devel] [PATCH] directsound: fix uninitialized var usage on error path
Thomas Guillem
thomas at gllm.fr
Mon Sep 9 17:42:23 CEST 2019
When directsound was used via mmdevice, a failing CreateDSBufferPCM() triggered
an invalid vlc_cancel call on the uninitialized thread variable.
CID 374810d1-d1be-4a63-a5af-5349cb6607d1
---
modules/audio_output/directsound.c | 31 ++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 45f5885734..8e1ae24bba 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -791,19 +791,8 @@ static HRESULT Start( vlc_object_t *obj, aout_stream_sys_t *sys,
if( ret != ENOMEM )
msg_Err( obj, "Couldn't start eraser thread" );
- vlc_cond_destroy(&sys->cond);
- vlc_mutex_destroy(&sys->lock);
-
- if( sys->p_notify != NULL )
- {
- IDirectSoundNotify_Release( sys->p_notify );
- sys->p_notify = NULL;
- }
- IDirectSoundBuffer_Release( sys->p_dsbuffer );
- sys->p_dsbuffer = NULL;
- IDirectSound_Release( sys->p_dsobject );
- sys->p_dsobject = NULL;
- return ret;
+ hr = E_FAIL;
+ goto error;
}
fmt.channel_type = AUDIO_CHANNEL_TYPE_BITMAP;
@@ -817,7 +806,21 @@ static HRESULT Start( vlc_object_t *obj, aout_stream_sys_t *sys,
return DS_OK;
error:
- Stop( sys );
+ vlc_cond_destroy(&sys->cond);
+ vlc_mutex_destroy(&sys->lock);
+
+ if( sys->p_notify != NULL )
+ {
+ IDirectSoundNotify_Release( sys->p_notify );
+ sys->p_notify = NULL;
+ }
+ if( sys->p_dsbuffer != NULL )
+ {
+ IDirectSoundBuffer_Release( sys->p_dsbuffer );
+ sys->p_dsbuffer = NULL;
+ }
+ IDirectSound_Release( sys->p_dsobject );
+ sys->p_dsobject = NULL;
return hr;
}
--
2.20.1
More information about the vlc-devel
mailing list