diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-17 06:56:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 06:56:27 (GMT) |
commit | be257bcad12b1d72a2c2a8199d2291ae22bccf78 (patch) | |
tree | 3fd63f1fa65acf8068a06bae2c3acf6a74b39431 /Modules | |
parent | 5d55d52b61f56522e616ac1423437d4e3f641ce6 (diff) | |
download | cpython-be257bcad12b1d72a2c2a8199d2291ae22bccf78.zip cpython-be257bcad12b1d72a2c2a8199d2291ae22bccf78.tar.gz cpython-be257bcad12b1d72a2c2a8199d2291ae22bccf78.tar.bz2 |
[2.7] bpo-38175: Fix a memory leak in comparison of sqlite3.Row objects. (GH-16155). (GH-16215)
(cherry picked from commit 8debfa50407107ff2329d01081cdc12d359f1d12)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sqlite/row.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index 9ebe7b7..c0da329 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -199,14 +199,16 @@ static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, Py_INCREF(Py_NotImplemented); return Py_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_INCREF(Py_NotImplemented); return Py_NotImplemented; |