]> git.sesse.net Git - vlc/commitdiff
Cleanup MRLParse
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 12 Oct 2008 08:22:23 +0000 (11:22 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 12 Oct 2008 08:22:23 +0000 (11:22 +0300)
modules/control/http/http.h
modules/control/http/util.c

index 7bd9c0200432131c35f3f30d1382b1e5e75831ce..f069ee44a41c1ced742e9bb07c418daede9d6488 100644 (file)
@@ -127,7 +127,7 @@ char *ExtractURIString( const char *restrict psz_uri,
 int TestURIParam( char *psz_uri, const char *psz_name );
 
 /** This function parses a MRL */
-input_item_t *MRLParse( intf_thread_t *, char *psz, char *psz_name );
+input_item_t *MRLParse( intf_thread_t *, const char *psz, char *psz_name );
 
 /** Return the first word from a string (works in-place) */
 char *FirstWord( char *psz, char *new );
index 6220d23dd782cedb9d47c530307c6d91e08ba3d4..65a36df6aedcc92a614ecd44086444f8d5cfa910 100644 (file)
@@ -820,14 +820,12 @@ static char *FirstOption( char *psz, char *new )
         return NULL;
 }
 
-input_item_t *MRLParse( intf_thread_t *p_intf, char *_psz,
+input_item_t *MRLParse( intf_thread_t *p_intf, const char *mrl,
                                    char *psz_name )
 {
-    char *psz = strdup( _psz );
-    char *s_mrl = psz;
-    char *s_temp;
-    input_item_t * p_input = NULL;
-
+    char *psz = strdup( mrl ), *s_mrl = psz, *s_temp;
+    if( psz == NULL )
+        return NULL;
     /* extract the mrl */
     s_temp = FirstOption( s_mrl, s_mrl );
     if( s_temp == NULL )
@@ -835,7 +833,9 @@ input_item_t *MRLParse( intf_thread_t *p_intf, char *_psz,
         s_temp = s_mrl + strlen( s_mrl );
     }
 
-    p_input = input_item_New( p_intf, s_mrl, psz_name );
+    input_item_t *p_input = input_item_New( p_intf, s_mrl, psz_name );
+    if( p_input == NULL )
+        return NULL;
     s_mrl = s_temp;
 
     /* now we can take care of the options */
@@ -852,7 +852,6 @@ input_item_t *MRLParse( intf_thread_t *p_intf, char *_psz,
         s_mrl = s_temp;
     }
 
-    free( psz );
     return p_input;
 }