[librsvg] Plug a mem leak
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Plug a mem leak
- Date: Sat, 12 Nov 2011 20:29:40 +0000 (UTC)
commit 5467364437900be7e3ea03268b065b7b95060d06
Author: Christian Persch <chpe gnome org>
Date: Sat Nov 12 19:13:58 2011 +0100
Plug a mem leak
Don't leak the list entries of RsvgDefs:to-resolve when parsing the
file fails.
==17296== 13,627 (8 direct, 13,619 indirect) bytes in 1 blocks are definitely lost in loss record 210 of 211
==17296== at 0x402AD89: malloc (vg_replace_malloc.c:236)
==17296== by 0x4565BDA: standard_malloc (gmem.c:85)
==17296== by 0x4565F80: g_malloc (gmem.c:159)
==17296== by 0x4579C8D: g_slice_alloc (gslice.c:822)
==17296== by 0x457AD5A: g_slist_prepend (gslist.c:267)
==17296== by 0x403952F: rsvg_defs_add_resolver (rsvg-defs.c:183)
==17296== by 0x404F8CC: rsvg_node_use_set_atts (rsvg-structure.c:434)
==17296== by 0x4057E7C: rsvg_node_set_atts (rsvg-base.c:1939)
==17296== by 0x4057F08: rsvg_standard_element_start (rsvg-base.c:265)
==17296== by 0x40588F8: rsvg_start_element (rsvg-base.c:659)
rsvg-defs.c | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/rsvg-defs.c b/rsvg-defs.c
index 0c2b0f1..18176f9 100644
--- a/rsvg-defs.c
+++ b/rsvg-defs.c
@@ -156,6 +156,20 @@ rsvg_defs_register_memory (RsvgDefs * defs, RsvgNode * val)
g_ptr_array_add (defs->unnamed, val);
}
+static void
+rsvg_defs_free_toresolve (RsvgDefs *defs)
+{
+ GSList *l;
+
+ for (l = defs->toresolve; l ; l = l ->next) {
+ RsvgResolutionPending *data = l->data;
+
+ g_free (data->name);
+ g_free (data);
+ }
+ g_slist_free (defs->toresolve);
+}
+
void
rsvg_defs_free (RsvgDefs * defs)
{
@@ -169,6 +183,7 @@ rsvg_defs_free (RsvgDefs * defs)
g_ptr_array_free (defs->unnamed, TRUE);
g_hash_table_destroy (defs->externs);
+ rsvg_defs_free_toresolve (defs);
g_free (defs);
}
@@ -186,13 +201,14 @@ rsvg_defs_add_resolver (RsvgDefs * defs, RsvgNode ** tochange, const gchar * nam
void
rsvg_defs_resolve_all (RsvgDefs * defs)
{
- while (defs->toresolve) {
- RsvgResolutionPending *data;
- data = defs->toresolve->data;
- *(data->tochange) = rsvg_defs_lookup (defs, data->name);
- g_free (data->name);
- g_free (data);
- defs->toresolve = g_slist_delete_link (defs->toresolve, defs->toresolve);
+ GSList *l;
+ for (l = defs->toresolve; l ; l = l ->next) {
+ RsvgResolutionPending *data = l->data;
+
+ *(data->tochange) = rsvg_defs_lookup (defs, data->name);
}
+
+ rsvg_defs_free_toresolve (defs);
+ defs->toresolve = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]