From: <wt...@ke...> - 2009-03-04 15:24:55
|
Module: gst-plugins-base Branch: master Commit: 629f2dcee42db581a780a4b480ebb27000b7a41e URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=629f2dcee42db581a780a4b480ebb27000b7a41e Author: Wim Taymans <wim...@co...> Date: Wed Mar 4 16:11:20 2009 +0100 rtsp: fix the memory management of the url Constify the url parameter in _create. Make a copy of the url stored in the connection. Free the url when the connection is freed. --- gst-libs/gst/rtsp/gstrtspconnection.c | 9 +++++++-- gst-libs/gst/rtsp/gstrtspconnection.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 7d4c018..2e28396 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -247,10 +247,12 @@ build_reset (GstRTSPBuilder * builder) * The connection will not yet attempt to connect to @url, use * gst_rtsp_connection_connect(). * + * A copy of @url will be made. + * * Returns: #GST_RTSP_OK when @conn contains a valid connection. */ GstRTSPResult -gst_rtsp_connection_create (GstRTSPUrl * url, GstRTSPConnection ** conn) +gst_rtsp_connection_create (const GstRTSPUrl * url, GstRTSPConnection ** conn) { GstRTSPConnection *newconn; #ifdef G_OS_WIN32 @@ -275,7 +277,7 @@ gst_rtsp_connection_create (GstRTSPUrl * url, GstRTSPConnection ** conn) if ((newconn->fdset = gst_poll_new (TRUE)) == NULL) goto no_fdset; - newconn->url = url; + newconn->url = gst_rtsp_url_copy (url); newconn->fd0.fd = -1; newconn->fd1.fd = -1; newconn->timer = g_timer_new (); @@ -365,6 +367,8 @@ gst_rtsp_connection_accept (gint sock, GstRTSPConnection ** conn) /* now create the connection object */ gst_rtsp_connection_create (url, &newconn); + gst_rtsp_url_free (url); + ADD_POLLFD (newconn->fdset, &newconn->fd0, fd); /* both read and write initially */ @@ -1946,6 +1950,7 @@ gst_rtsp_connection_free (GstRTSPConnection * conn) g_free (conn->username); g_free (conn->passwd); gst_rtsp_connection_clear_auth_params (conn); + gst_rtsp_url_free (conn->url); g_free (conn); #ifdef G_OS_WIN32 WSACleanup (); diff --git a/gst-libs/gst/rtsp/gstrtspconnection.h b/gst-libs/gst/rtsp/gstrtspconnection.h index 245f470..cfa6c37 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.h +++ b/gst-libs/gst/rtsp/gstrtspconnection.h @@ -59,7 +59,7 @@ G_BEGIN_DECLS typedef struct _GstRTSPConnection GstRTSPConnection; /* opening/closing a connection */ -GstRTSPResult gst_rtsp_connection_create (GstRTSPUrl *url, GstRTSPConnection **conn); +GstRTSPResult gst_rtsp_connection_create (const GstRTSPUrl *url, GstRTSPConnection **conn); GstRTSPResult gst_rtsp_connection_accept (gint sock, GstRTSPConnection **conn); GstRTSPResult gst_rtsp_connection_connect (GstRTSPConnection *conn, GTimeVal *timeout); GstRTSPResult gst_rtsp_connection_close (GstRTSPConnection *conn); |