From bd17e7c6116c7f0de1781b9eb36b54c76e37df38 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 8 Oct 2005 08:50:37 +0000 Subject: [PATCH] gst/tcp/gstmultifdsink.c: Fix crasher when going to NULL multiple times. Original commit message from CVS: * gst/tcp/gstmultifdsink.c: (gst_multifdsink_class_init), (gst_multifdsink_finalize), (multifdsink_hash_remove), (gst_multifdsink_stop): Fix crasher when going to NULL multiple times. --- ChangeLog | 7 +++++++ gst/tcp/gstmultifdsink.c | 25 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd617589e8..2859d970b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-10-08 Wim Taymans + + * gst/tcp/gstmultifdsink.c: (gst_multifdsink_class_init), + (gst_multifdsink_finalize), (multifdsink_hash_remove), + (gst_multifdsink_stop): + Fix crasher when going to NULL multiple times. + 2005-10-06 Wim Taymans * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_event), diff --git a/gst/tcp/gstmultifdsink.c b/gst/tcp/gstmultifdsink.c index 3b8e432315..650357a331 100644 --- a/gst/tcp/gstmultifdsink.c +++ b/gst/tcp/gstmultifdsink.c @@ -221,6 +221,7 @@ gst_client_status_get_type (void) static void gst_multifdsink_base_init (gpointer g_class); static void gst_multifdsink_class_init (GstMultiFdSinkClass * klass); static void gst_multifdsink_init (GstMultiFdSink * multifdsink); +static void gst_multifdsink_finalize (GObject * object); static void gst_multifdsink_remove_client_link (GstMultiFdSink * sink, GList * link); @@ -293,6 +294,7 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass) gobject_class->set_property = gst_multifdsink_set_property; gobject_class->get_property = gst_multifdsink_get_property; + gobject_class->finalize = gst_multifdsink_finalize; g_object_class_install_property (gobject_class, ARG_PROTOCOL, g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in", @@ -463,6 +465,20 @@ gst_multifdsink_init (GstMultiFdSink * this) this->sync_method = DEFAULT_SYNC_METHOD; } +static void +gst_multifdsink_finalize (GObject * object) +{ + GstMultiFdSink *this; + + this = GST_MULTIFDSINK (object); + + CLIENTS_LOCK_FREE (this); + g_hash_table_destroy (this->fd_hash); + g_array_free (this->bufqueue, TRUE); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + void gst_multifdsink_add (GstMultiFdSink * sink, int fd) { @@ -1721,6 +1737,12 @@ socket_pair: } } +static gboolean +multifdsink_hash_remove (gpointer key, gpointer value, gpointer data) +{ + return TRUE; +} + static gboolean gst_multifdsink_stop (GstBaseSink * bsink) { @@ -1761,9 +1783,8 @@ gst_multifdsink_stop (GstBaseSink * bsink) gst_fdset_free (this->fdset); this->fdset = NULL; } + g_hash_table_foreach_remove (this->fd_hash, multifdsink_hash_remove, this); GST_FLAG_UNSET (this, GST_MULTIFDSINK_OPEN); - CLIENTS_LOCK_FREE (this); - g_hash_table_destroy (this->fd_hash); return TRUE; }