[vlc-devel] commit: Fix NULL dereferencing in playlist sorting - CID 141 ( Rafaël Carré )

git version control git at videolan.org
Fri May 30 17:51:19 CEST 2008


vlc | branch: 0.8.6-bugfix | Rafaël Carré <funman at videolan.org> | Fri May 30 17:36:54 2008 +0200| [4d44bc5cc60a4ed8f376a8295d5a9890683e7f0e]

Fix NULL dereferencing in playlist sorting - CID 141

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

 src/playlist/sort.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/playlist/sort.c b/src/playlist/sort.c
index b530d93..058fcad 100644
--- a/src/playlist/sort.c
+++ b/src/playlist/sort.c
@@ -309,7 +309,6 @@ int playlist_NodeGroup( playlist_t * p_playlist , int i_view,
                         playlist_item_t **pp_items,int i_item,
                         int i_mode, int i_type )
 {
-    char *psz_search = NULL;
     int i_nodes = 0;
     playlist_item_t **pp_nodes = NULL;
     playlist_item_t *p_node;
@@ -317,7 +316,8 @@ int playlist_NodeGroup( playlist_t * p_playlist , int i_view,
     int i,j;
     for( i = 0; i< i_item ; i++ )
     {
-        if( psz_search ) free( psz_search );
+        char *psz_search = NULL;
+
         if( i_mode == SORT_TITLE )
         {
             psz_search = strdup( pp_items[i]->input.psz_name );
@@ -338,7 +338,7 @@ int playlist_NodeGroup( playlist_t * p_playlist , int i_view,
                             _(VLC_META_INFO_CAT), _(VLC_META_GENRE) );
         }
 
-        if( psz_search && !strcmp( psz_search, "" ) )
+        if( !psz_search || !strcmp( psz_search, "" ) )
         {
             free( psz_search );
             psz_search = strdup( _("Undefined") );
@@ -363,6 +363,8 @@ int playlist_NodeGroup( playlist_t * p_playlist , int i_view,
             playlist_NodeAppend( p_playlist, i_view,
                                  pp_items[i],p_node );
         }
+
+        free( psz_search );
     }
 
     /* Now, sort the nodes by name */




More information about the vlc-devel mailing list