Fix a bug where 'tp_richcompare' could end up overwriting an exception.
(cherry picked from commit
35cff545db7c7912046c0ce5627db2e4d2b60f57)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
--- /dev/null
+Fix a bug in :class:`array.array` where an exception could end up being
+overwritten.
k = 1;
for (i = 0; i < Py_SIZE(va) && i < Py_SIZE(wa); i++) {
vi = getarrayitem(v, i);
+ if (vi == NULL) {
+ return NULL;
+ }
wi = getarrayitem(w, i);
- if (vi == NULL || wi == NULL) {
- Py_XDECREF(vi);
- Py_XDECREF(wi);
+ if (wi == NULL) {
+ Py_DECREF(vi);
return NULL;
}
k = PyObject_RichCompareBool(vi, wi, Py_EQ);