[vlc-devel] commit: Prevent a segfault with Xv video output and too bug image. ( Laurent Aimar )

git version control git at videolan.org
Sat Mar 14 19:46:21 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Mar 14 19:44:33 2009 +0100| [2f8325c31f664fd42a239ff04f3f63d7c0197418] | committer: Laurent Aimar 

Prevent a segfault with Xv video output and too bug image.

It should fix/workaround https://bugs.launchpad.net/ubuntu/+source/vlc/+bug/324911
but I am not sure if it is the right way.

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

 modules/video_output/x11/xcommon.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c
index 2b5129f..cd89701 100644
--- a/modules/video_output/x11/xcommon.c
+++ b/modules/video_output/x11/xcommon.c
@@ -2908,6 +2908,20 @@ IMAGE_TYPE * CreateShmImage( vout_thread_t *p_vout,
         return NULL;
     }
 
+    /* For too bug image, the buffer returned is sometimes too low, prevent
+     * VLC to segfault because of it
+     * FIXME is it normal ? Is there a way to detect it
+     * before (XvQueryBestSize did not) ? */
+    if( p_image->width < i_width || p_image->height < i_height )
+    {
+        msg_Err( p_vout, "cannot allocate shared image data with the right size "
+                         "(%dx%d instead of %dx%d)",
+                         p_image->width, p_image->height,
+                         i_width, i_height );
+        IMAGE_FREE( p_image );
+        return NULL;
+    }
+
     /* Allocate shared memory segment - 0776 set the access permission
      * rights (like umask), they are not yet supported by all X servers */
     p_shm->shmid = shmget( IPC_PRIVATE, DATA_SIZE(p_image), IPC_CREAT | 0776 );




More information about the vlc-devel mailing list