summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2006-03-09 20:21:36 +0000
committerJohan Dahlin <johan@src.gnome.org>2006-03-09 20:21:36 +0000
commit3d0e57acc8d77543a0c96e454812329f3c24cecb (patch)
treeb22cf6ac12ff384106407c688cff83e58d7a19eb
parent27f518f39cd6203e9e72d644787aa3b704646db8 (diff)
downloadpygobject-3d0e57acc8d77543a0c96e454812329f3c24cecb.tar.gz
pygobject-3d0e57acc8d77543a0c96e454812329f3c24cecb.tar.xz
pygobject-3d0e57acc8d77543a0c96e454812329f3c24cecb.zip
reviewed by: Johan Dahlin <jdahlin@async.com.br>
* gobject/pygenum.c: (pyg_enum_new), (pyg_enum_from_gtype), (pyg_enum_add): * gobject/pygflags.c: (pyg_flags_new), (pyg_flags_from_gtype), (pyg_flags_add): Plug a couple of leaks, fixes #334027.
-rw-r--r--ChangeLog10
-rw-r--r--gobject/pygenum.c18
-rw-r--r--gobject/pygflags.c20
3 files changed, 36 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index f59eab3..bf5edfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-03-09 Michael Smith <msmith@fluendo.com>
+
+ reviewed by: Johan Dahlin <jdahlin@async.com.br>
+
+ * gobject/pygenum.c: (pyg_enum_new), (pyg_enum_from_gtype),
+ (pyg_enum_add):
+ * gobject/pygflags.c: (pyg_flags_new), (pyg_flags_from_gtype),
+ (pyg_flags_add):
+ Plug a couple of leaks, fixes #334027.
+
2006-01-19 Johan Dahlin <johan@gnome.org>
* configure.ac (export_dynamic):
diff --git a/gobject/pygenum.c b/gobject/pygenum.c
index aa8907e..2c0ee12 100644
--- a/gobject/pygenum.c
+++ b/gobject/pygenum.c
@@ -73,7 +73,7 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "value", NULL };
long value;
- PyObject *pytc, *values, *ret;
+ PyObject *pytc, *values, *ret, *intvalue;
GType gtype;
GEnumClass *eclass;
@@ -117,7 +117,9 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
g_type_class_unref(eclass);
- ret = PyDict_GetItem(values, PyInt_FromLong(value));
+ intvalue = PyInt_FromLong(value);
+ ret = PyDict_GetItem(values, intvalue);
+ Py_DECREF(intvalue);
Py_DECREF(values);
if (ret)
Py_INCREF(ret);
@@ -130,7 +132,7 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyObject*
pyg_enum_from_gtype (GType gtype, int value)
{
- PyObject *pyclass, *values, *retval;
+ PyObject *pyclass, *values, *retval, *intvalue;
g_return_val_if_fail(gtype != G_TYPE_INVALID, NULL);
@@ -143,7 +145,9 @@ pyg_enum_from_gtype (GType gtype, int value)
values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict,
"__enum_values__");
- retval = PyDict_GetItem(values, PyInt_FromLong(value));
+ intvalue = PyInt_FromLong(value);
+ retval = PyDict_GetItem(values, intvalue);
+ Py_DECREF(intvalue);
if (!retval) {
PyErr_Clear();
retval = ((PyTypeObject *)pyclass)->tp_alloc((PyTypeObject *)pyclass, 0);
@@ -210,13 +214,15 @@ pyg_enum_add (PyObject * module,
values = PyDict_New();
for (i = 0; i < eclass->n_values; i++) {
- PyObject *item;
+ PyObject *item, *intval;
item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)stub, 0);
((PyIntObject*)item)->ob_ival = eclass->values[i].value;
((PyGEnum*)item)->gtype = gtype;
- PyDict_SetItem(values, PyInt_FromLong(eclass->values[i].value), item);
+ intval = PyInt_FromLong(eclass->values[i].value);
+ PyDict_SetItem(values, intval, item);
+ Py_DECREF(intval);
if (module) {
PyModule_AddObject(module,
diff --git a/gobject/pygflags.c b/gobject/pygflags.c
index 562ea02..2fcfa10 100644
--- a/gobject/pygflags.c
+++ b/gobject/pygflags.c
@@ -105,7 +105,7 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "value", NULL };
long value;
- PyObject *pytc, *values, *ret;
+ PyObject *pytc, *values, *ret, *pyint;
GType gtype;
GFlagsClass *eclass;
@@ -143,8 +143,11 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
g_type_class_unref(eclass);
- ret = PyDict_GetItem(values, PyInt_FromLong(value));
+ pyint = PyInt_FromLong(value);
+ ret = PyDict_GetItem(values, pyint);
+ Py_DECREF(pyint);
Py_DECREF(values);
+
if (ret)
Py_INCREF(ret);
else
@@ -155,7 +158,7 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyObject*
pyg_flags_from_gtype (GType gtype, int value)
{
- PyObject *pyclass, *values, *retval;
+ PyObject *pyclass, *values, *retval, *pyint;
g_return_val_if_fail(gtype != G_TYPE_INVALID, NULL);
@@ -169,7 +172,10 @@ pyg_flags_from_gtype (GType gtype, int value)
values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict,
"__flags_values__");
- retval = PyDict_GetItem(values, PyInt_FromLong(value));
+ pyint = PyInt_FromLong(value);
+ retval = PyDict_GetItem(values, pyint);
+ Py_DECREF(pyint);
+
if (!retval) {
PyErr_Clear();
@@ -234,13 +240,15 @@ pyg_flags_add (PyObject * module,
values = PyDict_New();
for (i = 0; i < eclass->n_values; i++) {
- PyObject *item;
+ PyObject *item, *intval;
item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)stub, 0);
((PyIntObject*)item)->ob_ival = eclass->values[i].value;
((PyGFlags*)item)->gtype = gtype;
- PyDict_SetItem(values, PyInt_FromLong(eclass->values[i].value), item);
+ intval = PyInt_FromLong(eclass->values[i].value);
+ PyDict_SetItem(values, intval, item);
+ Py_DECREF(intval);
if (module) {
PyModule_AddObject(module,