]> git.sesse.net Git - vlc/blobdiff - modules/access/dv.c
Fix potential double free (cid #1047496 and #1047497)
[vlc] / modules / access / dv.c
index d43d476311a2ba5d0eb4f904ff8511f204d62fb3..508a93560a1768bbf85a39a756f62421e40c70dd 100644 (file)
@@ -6,19 +6,19 @@
  *
  * Authors: Jean-Paul Saman <jpsaman at m2x dot nl>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -36,7 +36,7 @@
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
-#elif defined( WIN32 ) && !defined( UNDER_CE )
+#elif defined( _WIN32 )
 #   include <io.h>
 #endif
 
@@ -57,12 +57,12 @@ static block_t *Block( access_t * );
 static int Control( access_t *, int, va_list );
 
 vlc_module_begin ()
-    set_description( N_("Digital Video (Firewire/ieee1394)  input") )
+    set_description( N_("Digital Video (Firewire/ieee1394) input") )
     set_shortname( N_("DV") )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_ACCESS )
     set_capability( "access", 0 )
-    add_shortcut( "dv", "dv1394", "raw1394" )
+    add_shortcut( "dv", "raw1394" )
     set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -206,17 +206,22 @@ static int Open( vlc_object_t *p_this )
     p_sys->p_ev = calloc( 1, sizeof( *p_sys->p_ev ) );
     if( !p_sys->p_ev )
     {
-        msg_Err( p_access, "failed to create event thread" );
+        msg_Err( p_access, "failed to create event thread struct" );
         Close( p_this );
-        return VLC_EGENERIC;
+        return VLC_ENOMEM;
     }
 
     p_sys->p_ev->p_frame = NULL;
     p_sys->p_ev->pp_last = &p_sys->p_ev->p_frame;
     p_sys->p_ev->p_access = p_access;
     vlc_mutex_init( &p_sys->p_ev->lock );
-    vlc_clone( &p_sys->p_ev->thread, Raw1394EventThread,
-               p_sys->p_ev, VLC_THREAD_PRIORITY_OUTPUT );
+    if( vlc_clone( &p_sys->p_ev->thread, Raw1394EventThread,
+               p_sys->p_ev, VLC_THREAD_PRIORITY_OUTPUT ) )
+    {
+        msg_Err( p_access, "failed to clone event thread" );
+        Close( p_this );
+        return VLC_EGENERIC;
+    }
 
     return VLC_SUCCESS;
 }
@@ -397,7 +402,7 @@ Raw1394Handler(raw1394handle_t handle, unsigned char *data,
                 block_ChainAppend( &p_sys->p_frame, p_sys->p_ev->p_frame );
             }
             /* reset list */
-            p_sys->p_ev->p_frame = block_New( p_access, 144000 );
+            p_sys->p_ev->p_frame = block_Alloc( 144000 );
             p_sys->p_ev->pp_last = &p_sys->p_frame;
             vlc_mutex_unlock( &p_sys->lock );
         }