dtls: Fix memory leak

Keys were not correctly released when it was get as a property
nor when a second key was received

https://bugzilla.gnome.org/show_bug.cgi?id=749380
This commit is contained in:
Jose Antonio Santos Cadenas 2015-05-14 16:06:55 +02:00 committed by Sebastian Dröge
parent c6abd1632f
commit d625770a18
4 changed files with 16 additions and 0 deletions

View file

@ -404,6 +404,12 @@ on_key_received (GstDtlsConnection * connection, gpointer key, guint cipher,
self->srtp_auth = auth;
key_dup = g_memdup (key, GST_DTLS_SRTP_MASTER_KEY_LENGTH);
if (self->decoder_key) {
gst_buffer_unref (self->decoder_key);
self->decoder_key = NULL;
}
self->decoder_key =
gst_buffer_new_wrapped (key_dup, GST_DTLS_SRTP_MASTER_KEY_LENGTH);

View file

@ -509,6 +509,12 @@ on_key_received (GstDtlsConnection * connection, gpointer key, guint cipher,
self->srtp_auth = auth;
key_dup = g_memdup (key, GST_DTLS_SRTP_MASTER_KEY_LENGTH);
if (self->encoder_key) {
gst_buffer_unref (self->encoder_key);
self->encoder_key = NULL;
}
self->encoder_key =
gst_buffer_new_wrapped (key_dup, GST_DTLS_SRTP_MASTER_KEY_LENGTH);

View file

@ -381,6 +381,8 @@ on_decoder_request_key (GstElement * srtp_decoder,
break;
}
gst_buffer_unref (key_buffer);
return key_caps;
} else {
GST_WARNING_OBJECT (bin, "no srtp key available yet");

View file

@ -399,6 +399,8 @@ on_key_received (GObject * encoder, GstDtlsSrtpEnc * self)
"rtp-auth", auth,
"rtcp-auth", auth, "key", buffer, "random-key", FALSE, NULL);
gst_buffer_unref (buffer);
g_signal_emit (self, signals[SIGNAL_ON_KEY_SET], 0);
} else {
GST_DEBUG_OBJECT (self,