From 0d697e8b58b10d41c20c8fbda87d9ed58291a8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 11 Aug 2009 16:23:20 -0400 Subject: [PATCH] rtpdtmfsrc: Cleanup events on finalize Problem found by Laurent Glayal Fixes bug #591440 --- gst/dtmf/gstrtpdtmfsrc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gst/dtmf/gstrtpdtmfsrc.c b/gst/dtmf/gstrtpdtmfsrc.c index 738be59e3a..cdaa202a42 100644 --- a/gst/dtmf/gstrtpdtmfsrc.c +++ b/gst/dtmf/gstrtpdtmfsrc.c @@ -301,6 +301,16 @@ gst_rtp_dtmf_src_class_init (GstRTPDTMFSrcClass * klass) gstbasesrc_class->negotiate = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_negotiate); } +static void +gst_rtp_dtmf_src_event_free (GstRTPDTMFSrcEvent * event) +{ + if (event) { + g_free (event->payload); + event->payload = NULL; + g_free (event); + } +} + static void gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object, GstRTPDTMFSrcClass * g_class) { @@ -315,7 +325,8 @@ gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object, GstRTPDTMFSrcClass * g_class) object->interval = DEFAULT_PACKET_INTERVAL; object->packet_redundancy = DEFAULT_PACKET_REDUNDANCY; - object->event_queue = g_async_queue_new (); + object->event_queue = + g_async_queue_new_full ((GDestroyNotify) gst_rtp_dtmf_src_event_free); object->payload = NULL; GST_DEBUG_OBJECT (object, "init done"); @@ -997,7 +1008,7 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition) /* Flushing the event queue */ while ((event = g_async_queue_try_pop (dtmfsrc->event_queue)) != NULL) - g_free (event); + gst_rtp_dtmf_src_event_free (event); no_preroll = TRUE; break; @@ -1018,7 +1029,7 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition) /* Flushing the event queue */ while ((event = g_async_queue_try_pop (dtmfsrc->event_queue)) != NULL) - g_free (event); + gst_rtp_dtmf_src_event_free (event); /* Indicate that we don't do PRE_ROLL */ break;