From 44dd0b86e9b68f4f00511e943afd37e589bd38a3 Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman Date: Thu, 27 Dec 2007 14:31:43 +0000 Subject: [PATCH] Fix segfault when Connect() returned failure and fix memleaks. Make sure live555 modules exits while in Connect() if vlc is asked to stop. --- modules/demux/live555.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index db4d1aef0d..7ab9e9486a 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -475,6 +475,14 @@ static int Connect( demux_t *p_demux ) } createnew: + if( p_demux->b_die || p_demux->b_error ) + { + free( psz_user ); + free( psz_pwd ); + free( psz_url ); + return VLC_EGENERIC; + } + if( var_CreateGetBool( p_demux, "rtsp-http" ) ) i_http_port = var_CreateGetInteger( p_demux, "rtsp-http-port" ); @@ -484,6 +492,9 @@ createnew: { msg_Err( p_demux, "RTSPClient::createNew failed (%s)", p_sys->env->getResultMsg() ); + free( psz_user ); + free( psz_pwd ); + free( psz_url ); return VLC_EGENERIC; } @@ -510,18 +521,18 @@ describe: if( psz_options ) delete [] psz_options; p_sdp = p_sys->rtsp->describeURL( psz_url, &authenticator, - var_CreateGetBool( p_demux, "rtsp-kasenna" ) ); + var_GetBool( p_demux, "rtsp-kasenna" ) ); if( p_sdp == NULL ) { /* failure occurred */ int i_code = 0; const char *psz_error = p_sys->env->getResultMsg(); - msg_Dbg( p_demux, "DESCRIBE failed with %d: %s", i_code, psz_error ); - if( var_CreateGetBool( p_demux, "rtsp-http" ) ) + if( var_GetBool( p_demux, "rtsp-http" ) ) sscanf( psz_error, "%*s %*s HTTP GET %*s HTTP/%*u.%*u %3u %*s", &i_code ); else sscanf( psz_error, "%*sRTSP/%*s%3u", &i_code ); + msg_Dbg( p_demux, "DESCRIBE failed with %d: %s", i_code, psz_error ); if( i_code == 401 ) { @@ -542,7 +553,7 @@ describe: goto describe; } } - else if( !var_GetBool( p_demux, "rtsp-http" ) ) + else if( (i_code != 0) && !var_GetBool( p_demux, "rtsp-http" ) ) { /* Perhaps a firewall is being annoying. Try HTTP tunneling mode */ vlc_value_t val; @@ -550,19 +561,21 @@ describe: msg_Dbg( p_demux, "we will now try HTTP tunneling mode" ); var_Set( p_demux, "rtsp-http", val ); if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp ); + p_sys->rtsp = NULL; goto createnew; } else { msg_Dbg( p_demux, "connection timeout, retrying" ); if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp ); + p_sys->rtsp = NULL; goto createnew; } i_ret = VLC_EGENERIC; } - if( psz_url ) free( psz_url ); /* malloc-ated copy */ + if( psz_url ) free( psz_url ); if( psz_user ) free( psz_user ); if( psz_pwd ) free( psz_pwd ); -- 2.39.2