pyldb: Correct reference counting when returning bools
authorPetr Viktorin <pviktori@redhat.com>
Tue, 3 Mar 2015 21:29:06 +0000 (22:29 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 3 Mar 2015 22:20:06 +0000 (23:20 +0100)
Simply returning Py_True/PyFalse doesn't increment the bool object's
reference count.

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c

index 5bcff72a2117876fae240aae2603d9608673548b..9bbd4ba66bcecca4aebdd15b44ea1dea34cbe9e6 100644 (file)
@@ -457,7 +457,7 @@ static PyObject *py_ldb_dn_check_special(PyLdbDnObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "s", &name))
                return NULL;
 
-       return ldb_dn_check_special(self->dn, name)?Py_True:Py_False;
+       return PyBool_FromLong(ldb_dn_check_special(self->dn, name));
 }
 
 static int py_ldb_dn_compare(PyLdbDnObject *dn1, PyLdbDnObject *dn2)
@@ -507,7 +507,7 @@ static PyObject *py_ldb_dn_add_child(PyLdbDnObject *self, PyObject *args)
        if (!pyldb_Object_AsDn(NULL, py_other, dn_ldb_ctx(dn), &other))
                return NULL;
 
-       return ldb_dn_add_child(dn, other)?Py_True:Py_False;
+       return PyBool_FromLong(ldb_dn_add_child(dn, other));
 }
 
 static PyObject *py_ldb_dn_add_base(PyLdbDnObject *self, PyObject *args)
@@ -522,7 +522,7 @@ static PyObject *py_ldb_dn_add_base(PyLdbDnObject *self, PyObject *args)
        if (!pyldb_Object_AsDn(NULL, py_other, dn_ldb_ctx(dn), &other))
                return NULL;
 
-       return ldb_dn_add_base(dn, other)?Py_True:Py_False;
+       return PyBool_FromLong(ldb_dn_add_base(dn, other));
 }
 
 static PyObject *py_ldb_dn_remove_base_components(PyLdbDnObject *self, PyObject *args)
@@ -534,7 +534,7 @@ static PyObject *py_ldb_dn_remove_base_components(PyLdbDnObject *self, PyObject
 
        dn = pyldb_Dn_AsDn((PyObject *)self);
 
-       return ldb_dn_remove_base_components(dn, i)?Py_True:Py_False;
+       return PyBool_FromLong(ldb_dn_remove_base_components(dn, i));
 }
 
 static PyObject *py_ldb_dn_is_child_of(PyLdbDnObject *self, PyObject *args)