From 24e788fc4ce97ff643eac815cef3847a7a82bd70 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:10:42 +0000 Subject: Change real_setup_and_get_header to use goto a single exit path to simplify proper freeing of allocated data. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29619 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'stream/realrtsp/real.c') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index 5b9fabe7f7..ed3ad2d365 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -427,11 +427,11 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidt char *description=NULL; char *session_id=NULL; - rmff_header_t *h; + rmff_header_t *h = NULL; char *challenge1; char challenge2[41]; char checksum[9]; - char *subscribe; + char *subscribe = NULL; char *buf = xbuffer_init(256); char *mrl=rtsp_get_mrl(rtsp_session); unsigned int size; @@ -513,8 +513,7 @@ autherr: alert); } rtsp_send_ok(rtsp_session); - buf = xbuffer_free(buf); - return NULL; + goto out; } /* receive description */ @@ -528,8 +527,7 @@ autherr: if (size > MAX_DESC_BUF) { mp_msg(MSGT_STREAM, MSGL_ERR, "realrtsp: Content-length for description too big (> %uMB)!\n", MAX_DESC_BUF/(1024*1024) ); - xbuffer_free(buf); - return NULL; + goto out; } if (!rtsp_search_answers(rtsp_session,"ETag")) @@ -544,8 +542,7 @@ autherr: description=malloc(size+1); if( rtsp_read_data(rtsp_session, description, size) <= 0) { - buf = xbuffer_free(buf); - return NULL; + goto out; } description[size]=0; @@ -554,9 +551,7 @@ autherr: strcpy(subscribe, "Subscribe: "); h=real_parse_sdp(description, &subscribe, bandwidth); if (!h) { - subscribe = xbuffer_free(subscribe); - buf = xbuffer_free(buf); - return NULL; + goto out; } rmff_fix_header(h); @@ -619,6 +614,7 @@ autherr: /* and finally send a play request */ rtsp_request_play(rtsp_session,NULL); +out: subscribe = xbuffer_free(subscribe); buf = xbuffer_free(buf); return h; -- cgit v1.2.3 From 5c4a06530d13948b68e1acb34868bf80021be1aa Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:20:45 +0000 Subject: Fix several memleaks in real_setup_and_get_header git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29620 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stream/realrtsp/real.c') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index ed3ad2d365..dd0f5d4461 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -428,7 +428,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidt char *description=NULL; char *session_id=NULL; rmff_header_t *h = NULL; - char *challenge1; + char *challenge1 = NULL; char challenge2[41]; char checksum[9]; char *subscribe = NULL; @@ -617,6 +617,9 @@ autherr: out: subscribe = xbuffer_free(subscribe); buf = xbuffer_free(buf); + free(description); + free(session_id); + free(challenge1); return h; } -- cgit v1.2.3 From 079a64ae8d93cb30adedbd1ebd4a40b36e805a99 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:22:08 +0000 Subject: Make sure we do not strdup(NULL), avoids a crash with non-real streams. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29621 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stream/realrtsp/real.c') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index dd0f5d4461..a5b37f6e34 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -441,7 +441,10 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidt int i; /* get challenge */ - challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1")); + challenge1=rtsp_search_answers(rtsp_session,"RealChallenge1"); + if (!challenge1) + goto out; + challenge1=strdup(challenge1); #ifdef LOG printf("real: Challenge1: %s\n", challenge1); #endif -- cgit v1.2.3 From ac11b35a6a90fd121fb51ac4b808523f7dc7871a Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:44:26 +0000 Subject: Fix several more rtsp-related memleaks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29625 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stream/realrtsp/real.c') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index a5b37f6e34..29c88335be 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -249,7 +249,7 @@ static rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t b if (!desc->stream[i]->mlti_data) { len = 0; - buf = NULL; + buf = xbuffer_free(buf); } else len=select_mlti_data(desc->stream[i]->mlti_data, desc->stream[i]->mlti_data_size, rulematches[0], &buf); -- cgit v1.2.3 From d1e7b4dc6f7dedea721e699827ae41d23d9d0e97 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:55:36 +0000 Subject: Fix possible crashes with invalid SDPs that result in stream descriptions not being initialized. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29626 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'stream/realrtsp/real.c') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index 29c88335be..0206833301 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -235,6 +235,8 @@ static rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t b char b[64]; int rulematches[MAX_RULEMATCHES]; + if (!desc->stream[i]) + continue; #ifdef LOG printf("calling asmrp_match with:\n%s\n%u\n", desc->stream[i]->asm_rule_book, bandwidth); #endif -- cgit v1.2.3