summaryrefslogtreecommitdiffstats
path: root/gobject
diff options
context:
space:
mode:
authorGian Mario Tagliaretti <gianmt@src.gnome.org>2009-02-08 19:18:48 +0000
committerGian Mario Tagliaretti <gianmt@src.gnome.org>2009-02-08 19:18:48 +0000
commit8392f3d238484832a5d73a4602aad31f83a08f62 (patch)
tree15e34d4e120b98d05216b2fab501c30bb50ac190 /gobject
parent951050a809d4368ed6fba283feffca0e7f6d8607 (diff)
downloadpygobject-8392f3d238484832a5d73a4602aad31f83a08f62.tar.gz
pygobject-8392f3d238484832a5d73a4602aad31f83a08f62.tar.xz
pygobject-8392f3d238484832a5d73a4602aad31f83a08f62.zip
huge patch to fix memory leaks all over the place, fixes #568427
svn path=/trunk/; revision=1002
Diffstat (limited to 'gobject')
-rw-r--r--gobject/gobjectmodule.c3
-rw-r--r--gobject/pygobject.c9
-rw-r--r--gobject/pygtype.c3
3 files changed, 10 insertions, 5 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 84a1071..ecc28f9 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -965,13 +965,14 @@ get_type_name_for_class(PyTypeObject *class)
gint i, name_serial;
char name_serial_str[16];
PyObject *module;
- char *type_name;
+ char *type_name = NULL;
/* make name for new GType */
name_serial = 1;
/* give up after 1000 tries, just in case.. */
while (name_serial < 1000)
{
+ g_free(type_name);
snprintf(name_serial_str, 16, "-v%i", name_serial);
module = PyObject_GetAttrString((PyObject *)class, "__module__");
if (module && _PyUnicode_Check(module)) {
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index c2deb9c..25efc52 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -231,18 +231,19 @@ build_parameter_list(GObjectClass *class)
GParamSpec **props;
guint n_props = 0, i;
PyObject *prop_str;
- char *name;
PyObject *props_list;
props = g_object_class_list_properties(class, &n_props);
props_list = PyList_New(n_props);
for (i = 0; i < n_props; i++) {
+ char *name;
name = g_strdup(g_param_spec_get_name(props[i]));
/* hyphens cannot belong in identifiers */
g_strdelimit(name, "-", '_');
prop_str = _PyUnicode_FromString(name);
PyList_SetItem(props_list, i, prop_str);
+ g_free(name);
}
if (props)
@@ -400,12 +401,14 @@ static Py_ssize_t
PyGProps_length(PyGProps *self)
{
GObjectClass *class;
+ GParamSpec **props;
guint n_props;
class = g_type_class_ref(self->gtype);
- g_object_class_list_properties(class, &n_props);
+ props = g_object_class_list_properties(class, &n_props);
g_type_class_unref(class);
-
+ g_free(props);
+
return (Py_ssize_t)n_props;
}
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index b12133d..a5eb545 100644
--- a/gobject/pygtype.c
+++ b/gobject/pygtype.c
@@ -87,7 +87,7 @@ static PyObject *
_wrap_g_type_wrapper__get_name(PyGTypeWrapper *self, void *closure)
{
const char *name = g_type_name(self->type);
- return _PyUnicode_FromString(g_strdup(name ? name : "invalid"));
+ return _PyUnicode_FromString(name ? name : "invalid");
}
static PyObject *
@@ -860,6 +860,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj)
return -1;
string = g_string_new_len(buffer, len);
g_value_set_boxed(value, string);
+ g_string_free (string, TRUE);
break;
}
else if ((bm = pyg_type_lookup(G_VALUE_TYPE(value))) != NULL)