summaryrefslogtreecommitdiffstats
path: root/gst/rtsp
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-06-19 14:48:03 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-06-19 14:48:03 +0000
commitebce97adf5e17143ce16731c7cec7b03b292c4ec (patch)
tree9a6199dfc6f1667bda8ec70d717909d9af6a76ed /gst/rtsp
parent6fb347e76f12d8d956a06c2b51ae8a50abaa2c7d (diff)
gst/rtsp/rtspconnection.c: Use threadsafe inet_ntop to convert an ip number to a string.
Original commit message from CVS: * gst/rtsp/rtspconnection.c: (rtsp_connection_connect), (rtsp_connection_close), (rtsp_connection_free): Use threadsafe inet_ntop to convert an ip number to a string. Fixes #447961. Don't leak fd (and ip) when freeing a connection without first closing it.
Diffstat (limited to 'gst/rtsp')
-rw-r--r--gst/rtsp/rtspconnection.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/gst/rtsp/rtspconnection.c b/gst/rtsp/rtspconnection.c
index f96caf4d..36355318 100644
--- a/gst/rtsp/rtspconnection.c
+++ b/gst/rtsp/rtspconnection.c
@@ -175,7 +175,8 @@ rtsp_connection_connect (RTSPConnection * conn, GTimeVal * timeout)
struct sockaddr_in sa_in;
struct hostent *hostinfo;
char **addrs;
- gchar *ip;
+ const gchar *ip;
+ gchar ipbuf[INET_ADDRSTRLEN];
struct in_addr addr;
gint ret;
guint16 port;
@@ -207,7 +208,8 @@ rtsp_connection_connect (RTSPConnection * conn, GTimeVal * timeout)
goto not_ip; /* host not an IP host */
addrs = hostinfo->h_addr_list;
- ip = inet_ntoa (*(struct in_addr *) *addrs);
+ ip = inet_ntop (AF_INET, (struct in_addr *) addrs[0], ipbuf,
+ sizeof (ipbuf));
}
/* get the port from the url */
@@ -264,7 +266,7 @@ rtsp_connection_connect (RTSPConnection * conn, GTimeVal * timeout)
done:
conn->fd = fd;
- conn->ip = ip;
+ conn->ip = g_strdup (ip);
return RTSP_OK;
@@ -1000,6 +1002,9 @@ rtsp_connection_close (RTSPConnection * conn)
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
+ g_free (conn->ip);
+ conn->ip = NULL;
+
if (conn->fd != -1) {
res = CLOSE_SOCKET (conn->fd);
#ifdef G_OS_WIN32
@@ -1021,19 +1026,20 @@ sys_error:
RTSPResult
rtsp_connection_free (RTSPConnection * conn)
{
+ RTSPResult res;
+
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
#ifdef G_OS_WIN32
WSACleanup ();
#endif
-
+ res = rtsp_connection_close (conn);
g_timer_destroy (conn->timer);
g_free (conn->username);
g_free (conn->passwd);
-
g_free (conn);
- return RTSP_OK;
+ return res;
}
RTSPResult