vlc | branch: master | Rémi Duraffort <[email protected]> | Mon Dec 2 08:42:40 2013 +0100| [f5c082b5c5c012fcf7095fec366612da5329e846] | committer: Rémi Duraffort
rtsp: fix memory leaks and factorize (cid #1048938) > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f5c082b5c5c012fcf7095fec366612da5329e846 --- modules/misc/rtsp.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/modules/misc/rtsp.c b/modules/misc/rtsp.c index d484c25..434c76e 100644 --- a/modules/misc/rtsp.c +++ b/modules/misc/rtsp.c @@ -369,16 +369,15 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name, if( asprintf( &p_media->psz_rtsp_path, "%s%s", p_sys->psz_path, psz_name ) <0 ) - return NULL; + goto error; + p_media->p_rtsp_url = httpd_UrlNew( p_sys->p_rtsp_host, p_media->psz_rtsp_path, NULL, NULL ); if( !p_media->p_rtsp_url ) { msg_Err( p_vod, "cannot create RTSP url (%s)", p_media->psz_rtsp_path); - free( p_media->psz_rtsp_path ); - free( p_media ); - return NULL; + goto error; } msg_Dbg( p_vod, "created RTSP url: %s", p_media->psz_rtsp_path ); @@ -386,21 +385,12 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name, if( asprintf( &p_media->psz_rtsp_control_v4, "rtsp://%%s:%%d%s/trackID=%%d", p_media->psz_rtsp_path ) < 0 ) - { - httpd_UrlDelete( p_media->p_rtsp_url ); - free( p_media->psz_rtsp_path ); - free( p_media ); - return NULL; - } + goto error; + if( asprintf( &p_media->psz_rtsp_control_v6, "rtsp://[%%s]:%%d%s/trackID=%%d", p_media->psz_rtsp_path ) < 0 ) - { - httpd_UrlDelete( p_media->p_rtsp_url ); - free( p_media->psz_rtsp_path ); - free( p_media ); - return NULL; - } + goto error; httpd_UrlCatch( p_media->p_rtsp_url, HTTPD_MSG_SETUP, RtspCallback, (void*)p_media ); @@ -431,6 +421,17 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name, CommandPush( p_vod, RTSP_CMD_TYPE_ADD, p_media, NULL, 0, 0.0, NULL ); return p_media; + +error: + if( p_media ) + { + free( p_media->psz_rtsp_control_v4 ); + if( p_media->p_rtsp_url ) + httpd_UrlDelete( p_media->p_rtsp_url ); + free( p_media->psz_rtsp_path ); + free( p_media ); + } + return NULL; } static void MediaAskDel ( vod_t *p_vod, vod_media_t *p_media ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
