[vlc-devel] commit: Cleanup MRLParse ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Oct 12 13:13:17 CEST 2008


vlc | branch: 0.9-bugfix | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Oct 12 11:22:23 2008 +0300| [0c9138813efee7a92c6191d0b29999396f0900a7] | committer: Rémi Denis-Courmont 

Cleanup MRLParse
(cherry picked from commit 6094cb67f2c5511ced2f818c0abf242c549331a8)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c9138813efee7a92c6191d0b29999396f0900a7
---

 modules/control/http/http.h |    2 +-
 modules/control/http/util.c |   15 +++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/control/http/http.h b/modules/control/http/http.h
index 68c8187..014c814 100644
--- a/modules/control/http/http.h
+++ b/modules/control/http/http.h
@@ -127,7 +127,7 @@ char *ExtractURIString( 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 );
diff --git a/modules/control/http/util.c b/modules/control/http/util.c
index 5f068f8..5ee1400 100644
--- a/modules/control/http/util.c
+++ b/modules/control/http/util.c
@@ -833,14 +833,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 )
@@ -848,7 +846,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 */
@@ -865,7 +865,6 @@ input_item_t *MRLParse( intf_thread_t *p_intf, char *_psz,
         s_mrl = s_temp;
     }
 
-    free( psz );
     return p_input;
 }
 




More information about the vlc-devel mailing list