From 107ec13506484b10f63424c65f3bb67142265049 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Sun, 6 Feb 2011 17:57:37 +0100
Subject: [PATCH] Fix a memory leak in LdDiagramSymbol.
---
liblogdiag/ld-canvas.c | 16 ++++++++++++----
liblogdiag/ld-diagram-symbol.c | 4 ++--
liblogdiag/ld-diagram-symbol.h | 2 +-
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/liblogdiag/ld-canvas.c b/liblogdiag/ld-canvas.c
index 84aaf67..564a838 100644
--- a/liblogdiag/ld-canvas.c
+++ b/liblogdiag/ld-canvas.c
@@ -1022,11 +1022,16 @@ is_object_selected (LdCanvas *self, LdDiagramObject *object)
static LdSymbol *
resolve_diagram_symbol (LdCanvas *self, LdDiagramSymbol *diagram_symbol)
{
+ LdSymbol *symbol;
+ gchar *klass;
+
if (!self->priv->library)
return NULL;
- return ld_library_find_symbol (self->priv->library,
- ld_diagram_symbol_get_class (diagram_symbol));
+ klass = ld_diagram_symbol_get_class (diagram_symbol);
+ symbol = ld_library_find_symbol (self->priv->library, klass);
+ g_free (klass);
+ return symbol;
}
static gboolean
@@ -1789,8 +1794,11 @@ draw_symbol (LdDiagramSymbol *diagram_symbol, DrawData *data)
/* TODO: Resolve this better; draw a cross or whatever. */
if (!symbol)
{
- g_warning ("cannot find symbol `%s' in the library",
- ld_diagram_symbol_get_class (diagram_symbol));
+ gchar *klass;
+
+ klass = ld_diagram_symbol_get_class (diagram_symbol);
+ g_warning ("cannot find symbol `%s' in the library", klass);
+ g_free (klass);
return;
}
diff --git a/liblogdiag/ld-diagram-symbol.c b/liblogdiag/ld-diagram-symbol.c
index 370d6ec..8307ef4 100644
--- a/liblogdiag/ld-diagram-symbol.c
+++ b/liblogdiag/ld-diagram-symbol.c
@@ -116,10 +116,10 @@ ld_diagram_symbol_new (JsonObject *storage)
*
* Return value: the class of the symbol.
*/
-const gchar *
+gchar *
ld_diagram_symbol_get_class (LdDiagramSymbol *self)
{
- const gchar *klass;
+ gchar *klass;
g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), NULL);
g_object_get (self, "class", &klass, NULL);
diff --git a/liblogdiag/ld-diagram-symbol.h b/liblogdiag/ld-diagram-symbol.h
index f2e60e9..d96c0f0 100644
--- a/liblogdiag/ld-diagram-symbol.h
+++ b/liblogdiag/ld-diagram-symbol.h
@@ -53,7 +53,7 @@ struct _LdDiagramSymbolClass
GType ld_diagram_symbol_get_type (void) G_GNUC_CONST;
LdDiagramSymbol *ld_diagram_symbol_new (JsonObject *storage);
-const gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
+gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
void ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass);