[vlc-devel] commit: fb: do not segfault when OpenDisplay() fails in Create(). ( Jean-Paul Saman )

git version control git at videolan.org
Tue Feb 17 12:42:14 CET 2009


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Feb 11 17:05:32 2009 +0100| [94fb5c71c977c60204a0aa38c9271b0ff7b8b01e] | committer: Jean-Paul Saman 

fb: do not segfault when OpenDisplay() fails in Create().

When the plugin fails to open the framebuffer, then the mmap might
not have been done yet. In this case a segmentation fault will occur
when memset is called on p_sys->p_video. (p_sys->p_video is either NULL,
or MMAP_FAILED.)

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

 modules/video_output/fb.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/fb.c b/modules/video_output/fb.c
index 8aa5050..78dac63 100644
--- a/modules/video_output/fb.c
+++ b/modules/video_output/fb.c
@@ -941,9 +941,13 @@ 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 != NULL &&
+        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 )
     {




More information about the vlc-devel mailing list