]> git.sesse.net Git - vlc/blobdiff - modules/video_output/fb.c
directfb: fix potential memleak.
[vlc] / modules / video_output / fb.c
index eac3c2a1c3c9aa5691bf5641751913fdd96e2c00..8880b36a31c295ff3251882a284787718078f55f 100644 (file)
@@ -191,6 +191,8 @@ static int Create( vlc_object_t *p_this )
         return VLC_ENOMEM;
     memset( p_sys, 0, sizeof(vout_sys_t) );
 
+    p_sys->p_video = MAP_FAILED;
+
     p_vout->pf_init = Init;
     p_vout->pf_end = End;
     p_vout->pf_manage = Manage;
@@ -651,11 +653,8 @@ static void End( vout_thread_t *p_vout )
  *****************************************************************************/
 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
 {
-    switch( i_query )
-    {
-       default:
-            return vout_vaControlDefault( p_vout, i_query, args );
-    }
+    (void) p_vout; (void) i_query; (void) args;
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -916,7 +915,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
                               PROT_READ | PROT_WRITE, MAP_SHARED,
                               p_sys->i_fd, 0 );
 
-    if( p_sys->p_video == ((void*)-1) )
+    if( p_sys->p_video == MAP_FAILED )
     {
         msg_Err( p_vout, "cannot map video memory (%m)" );
 
@@ -944,9 +943,12 @@ static int OpenDisplay( vout_thread_t *p_vout )
  *****************************************************************************/
 static void CloseDisplay( vout_thread_t *p_vout )
 {
-    /* Clear display */
-    memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
-    munmap( p_vout->p_sys->p_video, p_vout->p_sys->i_page_size );
+    if( p_vout->p_sys->p_video != MAP_FAILED )
+    {
+        /* Clear display */
+        memset( p_vout->p_sys->p_video, 0, p_vout->p_sys->i_page_size );
+        munmap( p_vout->p_sys->p_video, p_vout->p_sys->i_page_size );
+    }
 
     if( p_vout->p_sys->i_fd >= 0 )
     {