[dia] svg: plug memory leaks triggered by path-variations.svg
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] svg: plug memory leaks triggered by path-variations.svg
- Date: Wed, 1 Jan 2014 16:31:31 +0000 (UTC)
commit acbfa8760d03f373063a74b8c3b1e1f250080ef6
Author: Hans Breuer <hans breuer org>
Date: Wed Jan 1 16:13:51 2014 +0100
svg: plug memory leaks triggered by path-variations.svg
lib/diatransformrenderer.c | 2 +-
lib/standard-path.c | 3 +++
plug-ins/svg/svg-import.c | 15 ++++++++++-----
3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/lib/diatransformrenderer.c b/lib/diatransformrenderer.c
index 0ede08b..e0f6827 100644
--- a/lib/diatransformrenderer.c
+++ b/lib/diatransformrenderer.c
@@ -537,7 +537,7 @@ draw_object (DiaRenderer *self,
/* This will call us again */
object->ops->draw(object, DIA_RENDERER (renderer));
if (matrix)
- g_queue_pop_tail (renderer->matrices);
+ g_free (g_queue_pop_tail (renderer->matrices));
}
/*!
diff --git a/lib/standard-path.c b/lib/standard-path.c
index f56cacf..4a90ca9 100644
--- a/lib/standard-path.c
+++ b/lib/standard-path.c
@@ -806,6 +806,9 @@ static void
stdpath_destroy (StdPath *stdpath)
{
object_destroy(&stdpath->object);
+ if (stdpath->pattern)
+ g_object_unref (stdpath->pattern);
+ g_free (stdpath->points);
/* but not the object itself */
}
/*!
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index 569d49f..cb97aa1 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -361,6 +361,7 @@ _css_parse_style (DiaSvgStyle *s, real user_scale,
if (style) {
dia_svg_parse_style_string (s, user_scale, style);
}
+ g_free (key);
}
}
@@ -753,6 +754,9 @@ read_text_svg(xmlNodePtr node, DiaSvgStyle *parent_style,
}
if (!any_tspan) {
str = xmlNodeGetContent(node);
+ /* so no valid multiline */
+ g_free (multiline);
+ multiline = NULL;
}
if(str || multiline) {
if (matrix)
@@ -1286,7 +1290,7 @@ read_gradient (xmlNodePtr node, DiaSvgStyle *parent_gs, GHashTable *pattern_ht,
str = xmlGetProp(child, (const xmlChar *)"offset");
if (str) {
- if (strrchr (str, '%'))
+ if (strrchr ((const char*)str, '%'))
offset = g_ascii_strtod ((const char*)str, NULL) / 100.0;
else
offset = g_ascii_strtod ((const char*)str, NULL);
@@ -1344,7 +1348,7 @@ read_style (xmlNodePtr node, GHashTable *ht)
}
g_match_info_free (info);
g_regex_unref (regex);
-
+ xmlFree (str);
}
if (style_type)
xmlFree (style_type);
@@ -1431,6 +1435,7 @@ _node_read_viewbox (xmlNodePtr root, DiaMatrix **mat)
}
}
}
+ g_strfreev (vals);
}
if (swidth)
@@ -1721,7 +1726,7 @@ read_defs (xmlNodePtr startnode,
if (val) {
DiaPattern *pat = read_gradient (node, parent_gs, pattern_ht, ctx);
if (pat)
- g_hash_table_insert (pattern_ht, g_strdup(val), pat);
+ g_hash_table_insert (pattern_ht, g_strdup((gchar *)val), pat);
xmlFree (val);
}
} else if(!xmlStrcmp(node->name, (const xmlChar *)"defs")) {
@@ -1957,8 +1962,8 @@ import_svg (xmlDocPtr doc, DiagramData *dia,
_node_read_viewbox (root, NULL);
{
- GHashTable *defs_ht = g_hash_table_new (g_str_hash, g_str_equal);
- GHashTable *style_ht = g_hash_table_new (g_str_hash, g_str_equal);
+ GHashTable *defs_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ GHashTable *style_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
GHashTable *pattern_ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
/* first read all definitions ... */
read_defs (root->xmlChildrenNode, NULL, defs_ht, style_ht, pattern_ht,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]