[vlc-commits] shoutcast: fix NULL deref on error

Rémi Denis-Courmont git at videolan.org
Mon Aug 25 20:02:44 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 25 21:02:37 2014 +0300| [ad22a4a41fa28a2e6bb90f9ec4d72b6c10e58926] | committer: Rémi Denis-Courmont

shoutcast: fix NULL deref on error

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

 modules/demux/playlist/shoutcast.c |   42 +++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/modules/demux/playlist/shoutcast.c b/modules/demux/playlist/shoutcast.c
index a7d7afc..499ba3d 100644
--- a/modules/demux/playlist/shoutcast.c
+++ b/modules/demux/playlist/shoutcast.c
@@ -314,28 +314,36 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
                     }
 
                     /* Create the item */
-                    input_item_t *p_input;
-                    resolve_xml_special_chars( psz_mrl );
-                    p_input = input_item_New( psz_mrl, psz_name );
-                    input_item_CopyOptions( p_input_node->p_item, p_input );
-                    free( psz_mrl );
+                    input_item_t *p_input = NULL;
+
+                    if( likely(psz_mrl != NULL) )
+                    {
+                        resolve_xml_special_chars( psz_mrl );
+                        p_input = input_item_New( psz_mrl, psz_name );
+                        free( psz_mrl );
+                    }
+
+                    if( likely(p_input != NULL) )
+                    {
+                        input_item_CopyOptions( p_input_node->p_item, p_input );
 
 #define SADD_INFO( type, field ) \
                     if( field ) \
                         input_item_AddInfo( p_input, _("Shoutcast"), \
                                             vlc_gettext(type), "%s", field )
-                    SADD_INFO( N_("Mime"), psz_mt );
-                    SADD_INFO( N_("Bitrate"), psz_br );
-                    SADD_INFO( N_("Listeners"), psz_lc );
-                    SADD_INFO( N_("Load"), psz_load );
-                    if( psz_genre )
-                        input_item_SetGenre( p_input, psz_genre );
-                    if( psz_ct )
-                        input_item_SetNowPlaying( p_input, psz_ct );
-                    if( psz_rt )
-                        input_item_SetRating( p_input, psz_rt );
-                    input_item_node_AppendItem( p_input_node, p_input );
-                    vlc_gc_decref( p_input );
+                        SADD_INFO( N_("Mime"), psz_mt );
+                        SADD_INFO( N_("Bitrate"), psz_br );
+                        SADD_INFO( N_("Listeners"), psz_lc );
+                        SADD_INFO( N_("Load"), psz_load );
+                        if( psz_genre )
+                            input_item_SetGenre( p_input, psz_genre );
+                        if( psz_ct )
+                            input_item_SetNowPlaying( p_input, psz_ct );
+                        if( psz_rt )
+                            input_item_SetRating( p_input, psz_rt );
+                        input_item_node_AppendItem( p_input_node, p_input );
+                        vlc_gc_decref( p_input );
+                    }
                     FREENULL( psz_base );
                     FREENULL( psz_name );
                     FREENULL( psz_mt );



More information about the vlc-commits mailing list