[pygobject] pyg_flags_get_value_names: fix a leak
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] pyg_flags_get_value_names: fix a leak
- Date: Wed, 14 Mar 2018 11:33:58 +0000 (UTC)
commit 4829e279ad8f91186f64df199652abc9bd852536
Author: Christoph Reiter <reiter christoph gmail com>
Date: Wed Mar 14 12:31:28 2018 +0100
pyg_flags_get_value_names: fix a leak
PyList_Append() is transfer-none for the value
gi/pygflags.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gi/pygflags.c b/gi/pygflags.c
index fa12341f..d286a986 100644
--- a/gi/pygflags.c
+++ b/gi/pygflags.c
@@ -431,9 +431,15 @@ pyg_flags_get_value_names(PyGFlags *self, void *closure)
g_assert(G_IS_FLAGS_CLASS(flags_class));
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_name));
+ for (i = 0; i < flags_class->n_values; i++) {
+ PyObject *value_name;
+
+ if ((PYGLIB_PyLong_AsUnsignedLong (self) & flags_class->values[i].value) ==
flags_class->values[i].value) {
+ value_name = PYGLIB_PyUnicode_FromString (flags_class->values[i].value_name);
+ PyList_Append (retval, value_name);
+ Py_DECREF (value_name);
+ }
+ }
g_type_class_unref(flags_class);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]