[gst-debugger] debugserver: fix memory leaks
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gst-debugger] debugserver: fix memory leaks
- Date: Wed, 25 Oct 2017 21:51:54 +0000 (UTC)
commit 31e96de3310d246d910d623e4460c5761740e940
Author: Marcin Kolny <marcin kolny gmail com>
Date: Wed Oct 25 22:44:06 2017 +0100
debugserver: fix memory leaks
src/common/serializer.c | 13 +++++++++----
src/debugserver/gstdebugserver.c | 6 ++++--
2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/common/serializer.c b/src/common/serializer.c
index a2dda78..faaeec3 100644
--- a/src/common/serializer.c
+++ b/src/common/serializer.c
@@ -13,6 +13,7 @@ gchar *
g_value_serialize (GValue * value, GType * type, InternalGType * internal_type)
{
GValue tmp = G_VALUE_INIT;
+ gchar *serialized_value = NULL;
if (G_TYPE_IS_FUNDAMENTAL (value->g_type)
&& value->g_type < G_TYPE_RESERVED_USER_FIRST) {
@@ -34,7 +35,7 @@ g_value_serialize (GValue * value, GType * type, InternalGType * internal_type)
} else if (value->g_type == GST_TYPE_CAPS) {
g_value_init (&tmp, G_TYPE_STRING);
*type = G_TYPE_STRING;
- g_value_set_string (&tmp, gst_caps_to_string (gst_value_get_caps (value)));
+ g_value_take_string (&tmp, gst_caps_to_string (gst_value_get_caps (value)));
*internal_type = INTERNAL_GTYPE_CAPS;
} else if (value->g_type == GST_TYPE_OBJECT) {
g_value_init (&tmp, G_TYPE_STRING);
@@ -48,7 +49,7 @@ g_value_serialize (GValue * value, GType * type, InternalGType * internal_type)
}
snprintf (buffer, 128, "(GstObject:name) %s", name);
*type = G_TYPE_STRING;
- g_value_set_string (&tmp, g_strdup (buffer));
+ g_value_set_string (&tmp, buffer);
*internal_type = INTERNAL_GTYPE_GST_OBJECT;
} else {
g_value_init (&tmp, G_TYPE_STRING);
@@ -56,10 +57,13 @@ g_value_serialize (GValue * value, GType * type, InternalGType * internal_type)
snprintf (buffer, 128, "%s", g_type_name (value->g_type));
*type = G_TYPE_STRING;
*internal_type = INTERNAL_GTYPE_UNKNOWN;
- g_value_set_string (&tmp, g_strdup (buffer));
+ g_value_set_string (&tmp, buffer);
}
- return gst_value_serialize (&tmp);
+ serialized_value = gst_value_serialize (&tmp);
+ g_value_unset (&tmp);
+
+ return serialized_value;
}
@@ -113,6 +117,7 @@ g_value_deserialize (GValue * value, GType type, InternalGType internal_type,
g_value_unset (value);
g_value_init (value, GST_TYPE_CAPS);
gst_value_set_caps (value, caps);
+ gst_caps_unref (caps);
break;
}
}
diff --git a/src/debugserver/gstdebugserver.c b/src/debugserver/gstdebugserver.c
index 1ba9db9..43a4e95 100644
--- a/src/debugserver/gstdebugserver.c
+++ b/src/debugserver/gstdebugserver.c
@@ -428,13 +428,15 @@ gst_debugserver_process_property_request (GstDebugserverTracer * self,
if (request->name == NULL || request->name[0] == '\0') {
spec =
- g_object_class_list_properties (G_OBJECT_CLASS (GST_ELEMENT_GET_CLASS
- (element)), &n_properties);
+ g_object_class_list_properties (G_OBJECT_GET_CLASS
+ (element), &n_properties);
for (i = 0; i < n_properties; i++) {
gst_debugserver_send_single_property (self, client, element,
spec[i]->name);
}
+
+ g_free (spec);
} else {
gst_debugserver_send_single_property (self, client, element, request->name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]