diff options
author | Peter Kjellerstedt <pkj@axis.com> | 2008-08-20 11:51:38 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2008-08-20 11:51:38 +0000 |
commit | 74314914704609541ca0da9bf1f52469ea5e1079 (patch) | |
tree | 3ddd289bffe323071a6457e0f4d6d91b355c2357 /gst/udp/gstmultiudpsink.c | |
parent | 0dfa54f45078e349e84772bc57be08bb0c556b47 (diff) |
gst/udp/: Avoid leaking internally allocated file descriptors when setting custom file descriptors. Fixes #543101.
Original commit message from CVS:
Patch by: Peter Kjellerstedt <pkj at axis com>
* gst/udp/gstdynudpsink.c: (gst_dynudpsink_init),
(gst_dynudpsink_finalize), (gst_dynudpsink_set_property),
(gst_dynudpsink_init_send), (gst_dynudpsink_close):
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_init),
(gst_multiudpsink_finalize), (gst_multiudpsink_set_property):
* gst/udp/gstudpsrc.c: (gst_udpsrc_finalize),
(gst_udpsrc_set_property):
Avoid leaking internally allocated file descriptors when setting
custom file descriptors. Fixes #543101.
Diffstat (limited to 'gst/udp/gstmultiudpsink.c')
-rw-r--r-- | gst/udp/gstmultiudpsink.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c index 1188b31a..e08613ea 100644 --- a/gst/udp/gstmultiudpsink.c +++ b/gst/udp/gstmultiudpsink.c @@ -105,9 +105,14 @@ enum }; #define CLOSE_IF_REQUESTED(udpctx) \ - if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) \ +G_STMT_START { \ + if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) { \ CLOSE_SOCKET(udpctx->sock); \ - udpctx->sock = -1; + if (udpctx->sock == udpctx->sockfd) \ + udpctx->sockfd = DEFAULT_SOCKFD; \ + } \ + udpctx->sock = DEFAULT_SOCK; \ +} G_STMT_END static void gst_multiudpsink_base_init (gpointer g_class); static void gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass); @@ -332,7 +337,7 @@ gst_multiudpsink_init (GstMultiUDPSink * sink) WSA_STARTUP (sink); sink->client_lock = g_mutex_new (); - sink->sock = -1; + sink->sock = DEFAULT_SOCK; sink->sockfd = DEFAULT_SOCKFD; sink->closefd = DEFAULT_CLOSEFD; sink->externalfd = (sink->sockfd != -1); @@ -352,6 +357,9 @@ gst_multiudpsink_finalize (GObject * object) g_list_foreach (sink->clients, (GFunc) free_client, NULL); g_list_free (sink->clients); + if (sink->sockfd >= 0 && sink->closefd) + CLOSE_SOCKET (sink->sockfd); + g_mutex_free (sink->client_lock); WSA_CLEANUP (object); @@ -517,6 +525,9 @@ gst_multiudpsink_set_property (GObject * object, guint prop_id, switch (prop_id) { case PROP_SOCKFD: + if (udpsink->sockfd >= 0 && udpsink->sockfd != udpsink->sock && + udpsink->closefd) + CLOSE_SOCKET (udpsink->sockfd); udpsink->sockfd = g_value_get_int (value); GST_DEBUG_OBJECT (udpsink, "setting SOCKFD to %d", udpsink->sockfd); break; |