Commit 0f03eb91 authored by Clément Stenac's avatar Clément Stenac

* Fix segfault when we have two announces with the same URI but different names on the network

parent 69a02cbe
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sap.c : SAP interface module * sap.c : SAP interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: sap.c,v 1.42 2003/12/11 20:40:37 zorglub Exp $ * $Id: sap.c,v 1.43 2003/12/12 15:37:23 zorglub Exp $
* *
* Authors: Arnaud Schauly <gitan@via.ecp.fr> * Authors: Arnaud Schauly <gitan@via.ecp.fr>
* Clment Stenac <zorglub@via.ecp.fr> * Clment Stenac <zorglub@via.ecp.fr>
...@@ -635,9 +635,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -635,9 +635,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
for( i = 0 ; i< p_intf->p_sys->i_announces ; i++ ) for( i = 0 ; i< p_intf->p_sys->i_announces ; i++ )
{ {
if( !strcmp(p_intf->p_sys->pp_announces[i]->psz_name, if( !strcmp(p_intf->p_sys->pp_announces[i]->psz_uri,
p_item->psz_name ) &&
!strcmp(p_intf->p_sys->pp_announces[i]->psz_uri,
p_item->psz_uri ) ) p_item->psz_uri ) )
{ {
return; return;
...@@ -647,9 +645,23 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -647,9 +645,23 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
playlist_AddItem ( p_playlist, p_item, PLAYLIST_CHECK_INSERT, PLAYLIST_END ); playlist_AddItem ( p_playlist, p_item, PLAYLIST_CHECK_INSERT, PLAYLIST_END );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
p_announce = (struct sap_announce_t *)malloc( p_announce = (struct sap_announce_t *)malloc(
sizeof(struct sap_announce_t *) ); sizeof(struct sap_announce_t) );
if( p_item->psz_name )
{
p_announce->psz_name = strdup( p_item->psz_name ); p_announce->psz_name = strdup( p_item->psz_name );
}
else
{
p_announce->psz_name = strdup( "" );
}
if( p_item->psz_uri )
{
p_announce->psz_uri = strdup( p_item->psz_uri ); p_announce->psz_uri = strdup( p_item->psz_uri );
}
else
{
p_announce->psz_uri = strdup( "" );
}
INSERT_ELEM( p_intf->p_sys->pp_announces, INSERT_ELEM( p_intf->p_sys->pp_announces,
p_intf->p_sys->i_announces, p_intf->p_sys->i_announces,
...@@ -748,7 +760,6 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -748,7 +760,6 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
} }
} }
/* Filling p_item->psz_uri */ /* Filling p_item->psz_uri */
if( b_http == VLC_FALSE ) if( b_http == VLC_FALSE )
{ {
...@@ -785,9 +796,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -785,9 +796,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
for( i = 0 ; i< p_intf->p_sys->i_announces ; i++ ) for( i = 0 ; i< p_intf->p_sys->i_announces ; i++ )
{ {
if( !strcmp(p_intf->p_sys->pp_announces[i]->psz_name, if( !strcmp(p_intf->p_sys->pp_announces[i]->psz_uri,
p_item->psz_name ) &&
!strcmp(p_intf->p_sys->pp_announces[i]->psz_uri,
p_item->psz_uri ) ) p_item->psz_uri ) )
{ {
return; return;
...@@ -795,12 +804,30 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -795,12 +804,30 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
} }
/* Enqueueing p_item in the playlist */ /* Enqueueing p_item in the playlist */
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
playlist_AddItem ( p_playlist, p_item, PLAYLIST_CHECK_INSERT, PLAYLIST_END ); FIND_ANYWHERE );
playlist_AddItem ( p_playlist, p_item,
PLAYLIST_CHECK_INSERT, PLAYLIST_END );
/* Store it in the list */
p_announce = (struct sap_announce_t *)malloc( p_announce = (struct sap_announce_t *)malloc(
sizeof(struct sap_announce_t *) ); sizeof(struct sap_announce_t) );
if( p_item->psz_name )
{
p_announce->psz_name = strdup( p_item->psz_name ); p_announce->psz_name = strdup( p_item->psz_name );
}
else
{
p_announce->psz_name = strdup( "" );
}
if( p_item->psz_uri )
{
p_announce->psz_uri = strdup( p_item->psz_uri ); p_announce->psz_uri = strdup( p_item->psz_uri );
}
else
{
p_announce->psz_uri = strdup( "" );
}
INSERT_ELEM( p_intf->p_sys->pp_announces, INSERT_ELEM( p_intf->p_sys->pp_announces,
p_intf->p_sys->i_announces, p_intf->p_sys->i_announces,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment