From b445a6a9ffb600e4aa87793c21186d457631d588 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Escudier?= Date: Thu, 24 Jun 2010 08:41:16 +0200 Subject: [PATCH] rtp : safety check. There was a small window of opportunity between RtspSetup and RtspAddId where this can happen. --- modules/stream_out/rtp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c index 0d6779c0ce..7587eff0be 100644 --- a/modules/stream_out/rtp.c +++ b/modules/stream_out/rtp.c @@ -680,9 +680,12 @@ static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url ) if( p_sys->p_mux != NULL ) { sout_stream_id_t *id = p_sys->es[0]; - id->rtsp_id = RtspAddId( p_sys->rtsp, id, GetDWBE( id->ssrc ), - p_sys->psz_destination, p_sys->i_ttl, - id->i_port, id->i_port + 1 ); + rtsp_stream_id_t *rtsp_id = RtspAddId( p_sys->rtsp, id, GetDWBE( id->ssrc ), + p_sys->psz_destination, p_sys->i_ttl, + id->i_port, id->i_port + 1 ); + vlc_mutex_lock( &p_sys->lock_es ); + id->rtsp_id = rtsp_id; + vlc_mutex_unlock( &p_sys->lock_es ); } } else if( ( url.psz_protocol && !strcasecmp( url.psz_protocol, "sap" ) ) || @@ -742,7 +745,7 @@ char *SDPGenerate( sout_stream_t *p_stream, const char *rtsp_url ) int inclport; vlc_mutex_lock( &p_sys->lock_es ); - if( unlikely(p_sys->i_es == 0) ) + if( unlikely(p_sys->i_es == 0 || (rtsp_url != NULL && !p_sys->es[0]->rtsp_id)) ) goto out; /* hmm... */ if( p_sys->psz_destination != NULL ) -- 2.39.2