[vlc-commits] directsound: fix uninitialized var usage on error path

Thomas Guillem git at videolan.org
Tue Sep 10 17:02:09 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Sep  9 17:37:30 2019 +0200| [ff5142ffbd168b6bf9640566b03be6defe146fda] | committer: Thomas Guillem

directsound: fix uninitialized var usage on error path

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ff5142ffbd168b6bf9640566b03be6defe146fda
---

 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;
 }
 



More information about the vlc-commits mailing list