ports/144086: multimedia/vlc-1.0.5_1, 3 does not compile on 6.4-STABLE [patch]

Mark Andrews marka at isc.org
Fri Feb 19 02:50:01 UTC 2010


>Number:         144086
>Category:       ports
>Synopsis:       multimedia/vlc-1.0.5_1,3 does not compile on 6.4-STABLE [patch]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 19 02:50:00 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Mark Andrews
>Release:        FreeBSD 6.4-STABLE i386
>Organization:
ISC
>Environment:
System: FreeBSD drugs.dv.isc.org 6.4-STABLE FreeBSD 6.4-STABLE #32: Tue Oct 6 14:39:58 EST 2009 marka at drugs.dv.isc.org:/usr/obj/usr/src/sys/DRUGS i386


>Description:

	vlc calls a unprotected posix_memalign().

>How-To-Repeat:

	attempt to compile vlc.

>Fix:

	All p_buffers assignments are calloc's so free should
	be NULL with the exception of memory allocated here.

	Mark

--- modules/access/v4l2.c.orig	2009-12-21 04:43:39.000000000 +1100
+++ modules/access/v4l2.c	2010-02-19 13:29:51.000000000 +1100
@@ -492,6 +492,9 @@
 {
     void *  start;
     size_t  length;
+#if !defined (HAVE_POSIX_MEMALIGN) && !defined (HAVE_MEMALIGN)
+    void *  free;
+#endif
 };
 
 struct demux_sys_t
@@ -1038,7 +1041,12 @@
         switch( p_sys->io )
         {
         case IO_METHOD_READ:
-            free( p_sys->p_buffers[0].start );
+#if !defined (HAVE_POSIX_MEMALIGN) && !defined (HAVE_MEMALIGN)
+	    if (p_sys->p_buffers[0].free)
+                free( p_sys->p_buffers[0].free );
+	    else
+#endif
+                free( p_sys->p_buffers[0].start );
             break;
 
         case IO_METHOD_MMAP:
@@ -1054,7 +1062,12 @@
         case IO_METHOD_USERPTR:
             for( i = 0; i < p_sys->i_nbuffers; ++i )
             {
-               free( p_sys->p_buffers[i].start );
+#if !defined (HAVE_POSIX_MEMALIGN) && !defined (HAVE_MEMALIGN)
+	       if (p_sys->p_buffers[0].free)
+                   free( p_sys->p_buffers[i].free );
+	       else
+#endif
+                   free( p_sys->p_buffers[i].start );
             }
             break;
 
@@ -1600,10 +1613,31 @@
 
     for( p_sys->i_nbuffers = 0; p_sys->i_nbuffers < 4; ++p_sys->i_nbuffers )
     {
+#if defined (HAVE_POSIX_MEMALIGN)
         p_sys->p_buffers[p_sys->i_nbuffers].length = i_buffer_size;
         if( posix_memalign( &p_sys->p_buffers[p_sys->i_nbuffers].start,
                 /* boundary */ i_page_size, i_buffer_size ) )
             goto open_failed;
+#elif defined (HAVE_MEMALIGN)
+        p_sys->p_buffers[p_sys->i_nbuffers].length = i_buffer_size;
+	p_sys->p_buffers[p_sys->i_nbuffers].start =
+	    memalign ( /* boundary */ i_page_size, i_buffer_size );
+	if (p_sys->p_buffers[p_sys->i_nbuffers].start == NULL)
+	    goto open_failed;
+#else
+	unsigned char *ptr;
+	size_t align = i_page_size - 1;
+
+        p_sys->p_buffers[p_sys->i_nbuffers].length = i_buffer_size;
+	ptr = malloc (i_buffer_size + align);
+	if ( ptr == NULL )
+	    goto open_failed;
+
+	p_sys->p_buffers[p_sys->i_nbuffers].free = ptr;
+	ptr += align;
+	p_sys->p_buffers[p_sys->i_nbuffers].start =
+		(void *)(((uintptr_t)ptr) & ~align);
+#endif
     }
 
     return VLC_SUCCESS;

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list