[vlc-commits] DirectSound: don't alloc p_sys if we're gonna fail

Jean-Baptiste Kempf git at videolan.org
Tue Sep 10 15:47:10 CEST 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Sep 10 15:35:59 2013 +0200| [9ddf97b4e63a2ecf88a01654473364e500e6ee3c] | committer: Jean-Baptiste Kempf

DirectSound: don't alloc p_sys if we're gonna fail

If DSOUND.DLL is unavailable, just fail fast.

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

 modules/audio_output/directx.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index fbcf0fc..177da95 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -861,18 +861,20 @@ static int DeviceSelect (audio_output_t *aout, const char *id)
 static int Open(vlc_object_t *obj)
 {
     audio_output_t *aout = (audio_output_t *)obj;
-    aout_sys_t *sys = calloc(1, sizeof (*sys));
-    if (unlikely(sys == NULL))
-        return VLC_ENOMEM;
 
-    sys->hdsound_dll = LoadLibrary(_T("DSOUND.DLL"));
-    if (sys->hdsound_dll == NULL)
+    HINSTANCE hdsound_dll = LoadLibrary(_T("DSOUND.DLL"));
+    if (hdsound_dll == NULL)
     {
         msg_Warn(aout, "cannot open DSOUND.DLL");
-        free(sys);
         return VLC_EGENERIC;
     }
 
+    aout_sys_t *sys = calloc(1, sizeof (*sys));
+    if (unlikely(sys == NULL))
+        return VLC_ENOMEM;
+
+    sys->hdsound_dll = hdsound_dll;
+
     aout->sys = sys;
     aout->start = Start;
     aout->stop = Stop;



More information about the vlc-commits mailing list