[vlc-devel] commit: Cleanup and fix a potential memleak. ( Rémi Duraffort )

git version control git at videolan.org
Fri Oct 31 22:38:22 CET 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Oct 31 22:10:57 2008 +0100| [77950f05cc5dc7f48a8c8437e17690a89209125d] | committer: Rémi Duraffort 

Cleanup and fix a potential memleak.

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

 modules/demux/playlist/xspf.c |   44 +++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index cca6f9e..a9617dd 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -553,34 +553,32 @@ static bool parse_track_node COMPLEX_INTERFACE
                     }
                     psz_uri = decode_URI_duplicate( psz_value );
 
-                    if( psz_uri )
+                    if( !psz_uri )
                     {
-                        if( p_demux->p_sys->psz_base &&
-                            !strstr( psz_uri, "://" ) )
-                        {
-                           char* psz_tmp = malloc(
-                                   strlen(p_demux->p_sys->psz_base) +
-                                   strlen(psz_uri) +1 );
-                           if( !psz_tmp )
-                               return false;
-                           sprintf( psz_tmp, "%s%s",
-                                    p_demux->p_sys->psz_base, psz_uri );
-                           free( psz_uri );
-                           psz_uri = psz_tmp;
-                        }
-                        p_new_input = input_item_NewExt( p_demux, psz_uri,
-                                                        NULL, 0, NULL, -1 );
-                        free( psz_uri );
-                        input_item_CopyOptions( p_input_item, p_new_input );
-                        psz_uri = NULL;
                         FREE_ATT();
-                        p_handler = NULL;
+                        return false;
                     }
-                    else
+
+                    if( p_demux->p_sys->psz_base && !strstr( psz_uri, "://" ) )
                     {
-                        FREE_ATT();
-                        return false;
+                        char* psz_tmp;
+                        if( asprintf( &psz_tmp, "%s%s", p_demux->p_sys->psz_base,
+                                      psz_uri ) == -1 )
+                        {
+                            free( psz_uri );
+                            FREE_ATT();
+                            return NULL;
+                        }
+                        free( psz_uri );
+                        psz_uri = psz_tmp;
                     }
+                    p_new_input = input_item_NewExt( p_demux, psz_uri,
+                                                        NULL, 0, NULL, -1 );
+                    free( psz_uri );
+                    input_item_CopyOptions( p_input_item, p_new_input );
+                    psz_uri = NULL;
+                    FREE_ATT();
+                    p_handler = NULL;
                 }
                 else
                 {




More information about the vlc-devel mailing list