[dia] Plug all leaks after DiaObject::destroy()
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Plug all leaks after DiaObject::destroy()
- Date: Sun, 22 Jul 2012 18:03:35 +0000 (UTC)
commit c59acc29333a0d21d37b270e6f91b4938f27ae90
Author: Hans Breuer <hans breuer org>
Date: Sun Jul 22 20:02:44 2012 +0200
Plug all leaks after DiaObject::destroy()
app/disp_callbacks.c | 1 +
lib/object_defaults.c | 1 +
plug-ins/python/pydia-object.c | 2 ++
plug-ins/svg/svg-import.c | 7 +++++--
tests/test-objects.c | 11 ++++++++++-
5 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c
index 4005228..e83b26d 100644
--- a/app/disp_callbacks.c
+++ b/app/disp_callbacks.c
@@ -1097,6 +1097,7 @@ ddisplay_drop_object(DDisplay *ddisp, gint x, gint y, DiaObjectType *otype,
message_error(_("The object you dropped cannot fit into its parent. \nEither expand the parent object, or drop the object elsewhere."));
obj->parent->children = g_list_remove(obj->parent->children, obj);
obj->ops->destroy (obj);
+ g_free (obj);
return NULL;
}
diff --git a/lib/object_defaults.c b/lib/object_defaults.c
index 20ad2b5..b8d3e3e 100644
--- a/lib/object_defaults.c
+++ b/lib/object_defaults.c
@@ -75,6 +75,7 @@ _obj_destroy (gpointer val)
DiaObject *obj = (DiaObject *)val;
obj->ops->destroy (obj);
+ g_free (obj);
}
/**
diff --git a/plug-ins/python/pydia-object.c b/plug-ins/python/pydia-object.c
index afceb6e..0f98d26 100644
--- a/plug-ins/python/pydia-object.c
+++ b/plug-ins/python/pydia-object.c
@@ -85,6 +85,8 @@ PyDiaObject_Destroy(PyDiaObject *self, PyObject *args)
}
self->object->ops->destroy(self->object);
+ g_free(self->object);
+ self->object = NULL;
Py_INCREF(Py_None);
return Py_None;
}
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index 2201dac..2624e78 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -914,10 +914,12 @@ add_def (gpointer data,
DiaObject *obj = (DiaObject *)data;
GHashTable *defs_ht = (GHashTable *)user_data;
gchar *id = dia_object_get_meta (obj, "id");
- if (id) /* pass ownership of name and object */
+ if (id) { /* pass ownership of name and object */
g_hash_table_insert (defs_ht, id, obj);
- else
+ } else {
obj->ops->destroy (obj);
+ g_free (obj);
+ }
}
/*!
@@ -1048,6 +1050,7 @@ read_items (xmlNodePtr startnode,
} else {
/* just loose the object */
otemp->ops->destroy (otemp);
+ g_free (otemp);
list->data = NULL;
}
#endif
diff --git a/tests/test-objects.c b/tests/test-objects.c
index 6fcb438..b0dfebb 100644
--- a/tests/test-objects.c
+++ b/tests/test-objects.c
@@ -111,6 +111,7 @@ _test_creation (const DiaObjectType *type)
/* finally */
o->ops->destroy (o);
+ g_free (o);
}
static void
@@ -158,7 +159,9 @@ _test_copy (const DiaObjectType *type)
/* finally */
o->ops->destroy (o);
+ g_free (o);
oc->ops->destroy (oc);
+ g_free (oc);
}
/* samll helper to just throw it away */
@@ -234,6 +237,7 @@ _test_movement (const DiaObjectType *type)
/* finally */
o->ops->destroy (o);
+ g_free (o);
}
static void
@@ -265,6 +269,7 @@ _test_change (const DiaObjectType *type)
}
/* finally */
o->ops->destroy (o);
+ g_free (o);
}
static void
_test_move_handle (const DiaObjectType *type)
@@ -337,8 +342,11 @@ _test_move_handle (const DiaObjectType *type)
}
/* finally */
o->ops->destroy (o);
- if (o2)
+ g_free (o);
+ if (o2) {
o2->ops->destroy (o2);
+ g_free (o2);
+ }
}
static void
_test_connectionpoint_consistency (const DiaObjectType *type)
@@ -382,6 +390,7 @@ _test_connectionpoint_consistency (const DiaObjectType *type)
}
/* finally */
o->ops->destroy (o);
+ g_free (o);
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]