diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-06-11 09:58:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-11 09:58:08 (GMT) |
commit | 35cff545db7c7912046c0ce5627db2e4d2b60f57 (patch) | |
tree | 905600bf9639dca683abc94f04de4bcf0cc6f5bc /Modules | |
parent | 01f4230460454d4a849a5ba93320142c1a0c93a8 (diff) | |
download | cpython-35cff545db7c7912046c0ce5627db2e4d2b60f57.zip cpython-35cff545db7c7912046c0ce5627db2e4d2b60f57.tar.gz cpython-35cff545db7c7912046c0ce5627db2e4d2b60f57.tar.bz2 |
gh-105375: Improve array.array exception handling (#105594)
Fix a bug where 'tp_richcompare' could end up overwriting an exception.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/arraymodule.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 1a59938..8132689 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -767,10 +767,12 @@ array_richcompare(PyObject *v, PyObject *w, int op) 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); |