summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-06-11 10:24:22 (GMT)
committerGitHub <noreply@github.com>2023-06-11 10:24:22 (GMT)
commitd3c69ed366fb6504bb1a02f7d7226b9f788b403a (patch)
treed6a9d0686ad2d6fc00ab9d84d6bd0552297f2d12 /Modules
parentbf6e0e618ac2444b00ab72eb60b278a070e47397 (diff)
downloadcpython-d3c69ed366fb6504bb1a02f7d7226b9f788b403a.zip
cpython-d3c69ed366fb6504bb1a02f7d7226b9f788b403a.tar.gz
cpython-d3c69ed366fb6504bb1a02f7d7226b9f788b403a.tar.bz2
[3.12] gh-105375: Improve array.array exception handling (GH-105594) (#105644)
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>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/arraymodule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index f94bbec..6680820 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -739,10 +739,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);