]> git.sesse.net Git - vlc/blobdiff - modules/access_filter/timeshift.c
Check asprintf return value.
[vlc] / modules / access_filter / timeshift.c
index da4284e4d9e528108a8f22cae90963e841d383e4..924744a5aff2ebfb7497f7531f25de3a2e8c2363 100644 (file)
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 
 #include <errno.h>
@@ -85,7 +85,7 @@ vlc_module_end();
 static int      Seek( access_t *, int64_t );
 static block_t *Block  ( access_t *p_access );
 static int      Control( access_t *, int i_query, va_list args );
-static void     Thread ( access_t *p_access );
+static void*    Thread ( vlc_object_t *p_this );
 static int      WriteBlockToFile( access_t *p_access, block_t *p_block );
 static block_t *ReadBlockFromFile( access_t *p_access );
 static char    *GetTmpFilePath( access_t *p_access );
@@ -269,13 +269,14 @@ static block_t *Block( access_t *p_access )
 /*****************************************************************************
  *
  *****************************************************************************/
-static void Thread( access_t *p_access )
+static void* Thread( vlc_object_t* p_this )
 {
+    access_t *p_access = (access_t*)p_this;
     access_sys_t *p_sys = p_access->p_sys;
     access_t     *p_src = p_access->p_source;
     block_t      *p_block;
 
-    while( !p_access->b_die )
+    while( vlc_object_alive (p_access) )
     {
         /* Get a new block from the source */
         if( p_src->pf_block )
@@ -320,7 +321,7 @@ static void Thread( access_t *p_access )
 
         /* Read from file to fill up the fifo */
         while( block_FifoSize( p_sys->p_fifo ) < TIMESHIFT_FIFO_MIN &&
-               !p_access->b_die )
+               vlc_object_alive (p_access) )
         {
             p_block = ReadBlockFromFile( p_access );
             if( !p_block ) break;
@@ -331,12 +332,12 @@ static void Thread( access_t *p_access )
 
     msg_Dbg( p_access, "timeshift: no more input data" );
 
-    while( !p_access->b_die &&
+    while( vlc_object_alive (p_access) &&
            (p_sys->p_read_list || block_FifoSize( p_sys->p_fifo ) ) )
     {
         /* Read from file to fill up the fifo */
         while( block_FifoSize( p_sys->p_fifo ) < TIMESHIFT_FIFO_MIN &&
-               !p_access->b_die && p_sys->p_read_list )
+               vlc_object_alive (p_access) && p_sys->p_read_list )
         {
             p_block = ReadBlockFromFile( p_access );
             if( !p_block ) break;
@@ -352,6 +353,7 @@ static void Thread( access_t *p_access )
 
     /* Send dummy packet to avoid deadlock in Block() */
     block_FifoPut( p_sys->p_fifo, block_New( p_access, 0 ) );
+    return NULL;
 }
 
 /*****************************************************************************
@@ -594,8 +596,9 @@ static char *GetTmpFilePath( access_t *p_access )
 #endif
     }
 
-    asprintf( &psz_filename_base, "%s/vlc-timeshift-%d-%d-",
-              psz_dir, getpid(), p_access->i_object_id );
+    if( asprintf( &psz_filename_base, "%s/vlc-timeshift-%d-%d-",
+              psz_dir, getpid(), p_access->i_object_id ) == -1 )
+        psz_filename_base = NULL;
     free( psz_dir );
 
     return psz_filename_base;