]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/asx.c
Remove useless test before a free (again).
[vlc] / modules / demux / playlist / asx.c
index 650f11cd8b050ebd0f991b74c8dd30f09739486f..de4a968ddb3ab84433ca005bb129effcc665f92b 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <ctype.h>                                              /* isspace() */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include <vlc/vlc.h>
 #include <vlc_demux.h>
 
-#include <errno.h>                                                 /* ENOMEM */
+#include <ctype.h>
 #include <vlc_charset.h>
 #include "playlist.h"
 #include "vlc_meta.h"
@@ -59,7 +61,7 @@ static int StoreString( demux_t *p_demux, char **ppsz_string,
     demux_sys_t *p_sys = p_demux->p_sys;
     unsigned len = psz_source_end - psz_source_start;
 
-    if( *ppsz_string ) free( *ppsz_string );
+    free( *ppsz_string );
 
     char *buf = *ppsz_string = malloc ((len * (1 + !p_sys->b_utf8)) + 1);
     if (buf == NULL)
@@ -186,7 +188,7 @@ static int ParseTime(char *s, size_t i_strlen)
 int E_(Import_ASX)( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
-    uint8_t *p_peek;
+    const uint8_t *p_peek;
     CHECK_PEEK( p_peek, 10 );
 
     // skip over possible leading empty lines and empty spaces
@@ -219,8 +221,8 @@ void E_(Close_ASX)( vlc_object_t *p_this )
     demux_t *p_demux = (demux_t *)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    if( p_sys->psz_prefix ) free( p_sys->psz_prefix );
-    if( p_sys->psz_data ) free( p_sys->psz_data );
+    free( p_sys->psz_prefix );
+    free( p_sys->psz_data );
     free( p_sys );
 }
 
@@ -253,7 +255,7 @@ static int Demux( demux_t *p_demux )
             p_sys->i_data_len += 1024;
             p_sys->psz_data = realloc( p_sys->psz_data, p_sys->i_data_len * sizeof( char * ) +1 );
         }
-        if( p_sys->i_data_len <= 0 ) return VLC_EGENERIC;
+        if( p_sys->i_data_len <= 0 ) return -1;
     }
 
     psz_parse = p_sys->psz_data;
@@ -529,16 +531,17 @@ static int Demux( demux_t *p_demux )
                     if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry );
                     if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry );
                     input_ItemAddSubItem( p_current_input, p_entry );
+                    vlc_gc_decref( p_entry );
                 }
 
-                /* cleanup entry */
-                FREENULL( psz_href )
-                FREENULL( psz_title_entry )
-                FREENULL( psz_base_entry )
-                FREENULL( psz_artist_entry )
-                FREENULL( psz_copyright_entry )
-                FREENULL( psz_moreinfo_entry )
-                FREENULL( psz_abstract_entry )
+                /* cleanup entry */;
+                FREENULL( psz_href );
+                FREENULL( psz_title_entry );
+                FREENULL( psz_base_entry );
+                FREENULL( psz_artist_entry );
+                FREENULL( psz_copyright_entry );
+                FREENULL( psz_moreinfo_entry );
+                FREENULL( psz_abstract_entry );
                 b_entry = VLC_FALSE;
             }
             else if( !strncasecmp( psz_parse, "<Entry", 6 ) )
@@ -665,13 +668,11 @@ static int Demux( demux_t *p_demux )
             }
             else if( !strncasecmp( psz_parse, "</ASX", 5 ) )
             {
-                vlc_mutex_lock( &p_current_input->lock );
                 if( psz_title_asx ) input_item_SetTitle( p_current_input, psz_title_asx );
                 if( psz_artist_asx ) input_item_SetArtist( p_current_input, psz_artist_asx );
                 if( psz_copyright_asx ) input_item_SetCopyright( p_current_input, psz_copyright_asx );
                 if( psz_moreinfo_asx ) input_item_SetURL( p_current_input, psz_moreinfo_asx );
                 if( psz_abstract_asx ) input_item_SetDescription( p_current_input, psz_abstract_asx );
-                vlc_mutex_unlock( &p_current_input->lock );
                 FREENULL( psz_base_asx );
                 FREENULL( psz_title_asx );
                 FREENULL( psz_artist_asx );
@@ -692,10 +693,11 @@ static int Demux( demux_t *p_demux )
 #endif
     }
     HANDLE_PLAY_AND_RELEASE;
-    return -1; /* Needed for correct operation of go back */
+    return 0; /* Needed for correct operation of go back */
 }
 
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
+    VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args);
     return VLC_EGENERIC;
 }