[pygobject] Fix memory leak in pyg_flags_get_value_nicks()
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix memory leak in pyg_flags_get_value_nicks()
- Date: Mon, 4 Mar 2013 11:45:04 +0000 (UTC)
commit eec8c3a932d42e92ccaf7f97d3d90948842e263f
Author: Martin Pitt <martinpitt gnome org>
Date: Mon Mar 4 12:43:24 2013 +0100
Fix memory leak in pyg_flags_get_value_nicks()
Discovered by test_gi.TestKeywords.test_uppercase() test.
gi/_gobject/pygflags.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gi/_gobject/pygflags.c b/gi/_gobject/pygflags.c
index bb12d4a..83aa4dc 100644
--- a/gi/_gobject/pygflags.c
+++ b/gi/_gobject/pygflags.c
@@ -434,8 +434,11 @@ pyg_flags_get_value_nicks(PyGFlags *self, void *closure)
retval = PyList_New(0);
for (i = 0; i < flags_class->n_values; i++)
- if ((PYGLIB_PyLong_AsUnsignedLong(self) & flags_class->values[i].value) ==
flags_class->values[i].value)
- PyList_Append(retval, PYGLIB_PyUnicode_FromString(flags_class->values[i].value_nick));
+ if ((PYGLIB_PyLong_AsUnsignedLong(self) & flags_class->values[i].value) ==
flags_class->values[i].value) {
+ PyObject *py_nick = PYGLIB_PyUnicode_FromString(flags_class->values[i].value_nick);
+ PyList_Append(retval, py_nick);
+ Py_DECREF (py_nick);
+ }
g_type_class_unref(flags_class);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]