summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-17 06:14:20 (GMT)
committerGitHub <noreply@github.com>2019-09-17 06:14:20 (GMT)
commitf04299d978793be33828dc4d5f46e9b54c81a0a2 (patch)
tree08089bb883ed09b9c2af4247efe3f80deb5ccd9e /Modules
parentd90bb231c27708f60e9812e0066e3620bc8cfe58 (diff)
downloadcpython-f04299d978793be33828dc4d5f46e9b54c81a0a2.zip
cpython-f04299d978793be33828dc4d5f46e9b54c81a0a2.tar.gz
cpython-f04299d978793be33828dc4d5f46e9b54c81a0a2.tar.bz2
bpo-38175: Fix a memory leak in comparison of sqlite3.Row objects. (GH-16155)
(cherry picked from commit 8debfa50407107ff2329d01081cdc12d359f1d12) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sqlite/row.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 5c2f400..758518a 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -192,14 +192,16 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other,
if (opid != Py_EQ && opid != Py_NE)
Py_RETURN_NOTIMPLEMENTED;
- if (PyType_IsSubtype(Py_TYPE(_other), &pysqlite_RowType)) {
+ if (PyObject_TypeCheck(_other, &pysqlite_RowType)) {
pysqlite_Row *other = (pysqlite_Row *)_other;
- PyObject *res = PyObject_RichCompare(self->description, other->description, opid);
- if ((opid == Py_EQ && res == Py_True)
- || (opid == Py_NE && res == Py_False)) {
- Py_DECREF(res);
+ int eq = PyObject_RichCompareBool(self->description, other->description, Py_EQ);
+ if (eq < 0) {
+ return NULL;
+ }
+ if (eq) {
return PyObject_RichCompare(self->data, other->data, opid);
}
+ return PyBool_FromLong(opid != Py_EQ);
}
Py_RETURN_NOTIMPLEMENTED;
}