mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
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.
This commit is contained in:
parent
b6d7a1dc03
commit
629f2dcee4
2 changed files with 8 additions and 3 deletions
|
@ -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 ();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue