[vlc-commits] vaapi: fix some memory leaks

Rémi Denis-Courmont git at videolan.org
Sat Mar 22 17:15:31 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 22 16:05:28 2014 +0200| [e59154b30a4d329c2ac9bda0a29bde74eab3181b] | committer: Rémi Denis-Courmont

vaapi: fix some memory leaks

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

 modules/codec/avcodec/vaapi.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 88023f3..bcad3fa 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * vaapi.c: VAAPI helpers for the libavcodec decoder
  *****************************************************************************
- * Copyright (C) 2009 Laurent Aimar
- * $Id$
+ * Copyright (C) 2009-2010 Laurent Aimar
+ * Copyright (C) 2012-2014 Rémi Denis-Courmont
  *
  * Authors: Laurent Aimar <fenrir_AT_ videolan _DOT_ org>
  *
@@ -218,7 +218,11 @@ static int Open( vlc_va_t *va, int i_codec_id, int i_thread_count )
     return VLC_SUCCESS;
 
 error:
-#warning Leaks!
+    if( sys->p_display != NULL )
+        vaTerminate( sys->p_display );
+    if( sys->p_display_x11 != NULL )
+        XCloseDisplay( sys->p_display_x11 );
+    free( sys );
     return VLC_EGENERIC;
 }
 
@@ -527,10 +531,8 @@ static void Close( vlc_va_sys_t *sys )
 
     if( sys->i_config_id != VA_INVALID_ID )
         vaDestroyConfig( sys->p_display, sys->i_config_id );
-    if( sys->p_display )
-        vaTerminate( sys->p_display );
-    if( sys->p_display_x11 )
-        XCloseDisplay( sys->p_display_x11 );
+    vaTerminate( sys->p_display );
+    XCloseDisplay( sys->p_display_x11 );
 }
 
 static void Delete( vlc_va_t *va )



More information about the vlc-commits mailing list