Commit 905295ea authored by Sebastian Rasmussen's avatar Sebastian Rasmussen Committed by Sebastian Dröge

rtptheoradepay: Fix memory leaks

The same memory leaks were fixed in identical fashion for
vorbisdepay in 06efeff5 in 2009.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=755277
parent 2d7bfc13
......@@ -74,6 +74,9 @@ static gboolean gst_rtp_theora_depay_packet_lost (GstRTPBaseDepayload *
static void gst_rtp_theora_depay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_theora_depay_change_state (GstElement *
element, GstStateChange transition);
static void
gst_rtp_theora_depay_class_init (GstRtpTheoraDepayClass * klass)
{
......@@ -87,6 +90,8 @@ gst_rtp_theora_depay_class_init (GstRtpTheoraDepayClass * klass)
gobject_class->finalize = gst_rtp_theora_depay_finalize;
gstelement_class->change_state = gst_rtp_theora_depay_change_state;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_theora_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_theora_depay_setcaps;
gstrtpbasedepayload_class->packet_lost = gst_rtp_theora_depay_packet_lost;
......@@ -111,6 +116,20 @@ gst_rtp_theora_depay_init (GstRtpTheoraDepay * rtptheoradepay)
rtptheoradepay->adapter = gst_adapter_new ();
}
static void
free_config (GstRtpTheoraConfig * config)
{
g_list_free_full (config->headers, (GDestroyNotify) gst_buffer_unref);
g_free (config);
}
static void
free_indents (GstRtpTheoraDepay * rtptheoradepay)
{
g_list_free_full (rtptheoradepay->configs, (GDestroyNotify) free_config);
rtptheoradepay->configs = NULL;
}
static void
gst_rtp_theora_depay_finalize (GObject * object)
{
......@@ -244,6 +263,7 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
h_size = h_sizes[j];
if (size < h_size) {
if (j != n_headers || size + extra != h_size) {
free_config (conf);
goto too_small;
} else {
/* otherwise means that overall length field contained total length,
......@@ -266,6 +286,8 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
}
gst_buffer_unmap (confbuf, &map);
gst_buffer_unref (confbuf);
return TRUE;
/* ERRORS */
......@@ -273,6 +295,7 @@ too_small:
{
GST_DEBUG_OBJECT (rtptheoradepay, "configuration too small");
gst_buffer_unmap (confbuf, &map);
gst_buffer_unref (confbuf);
return FALSE;
}
}
......@@ -625,6 +648,38 @@ request_keyframe:
}
}
static GstStateChangeReturn
gst_rtp_theora_depay_change_state (GstElement * element,
GstStateChange transition)
{
GstRtpTheoraDepay *rtptheoradepay;
GstStateChangeReturn ret;
rtptheoradepay = GST_RTP_THEORA_DEPAY (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
free_indents (rtptheoradepay);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
}
gboolean
gst_rtp_theora_depay_plugin_init (GstPlugin * plugin)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment