summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-06-11 10:06:06 (GMT)
committerGitHub <noreply@github.com>2023-06-11 10:06:06 (GMT)
commitc932f7284977ebf813313157c52d716ba225a7ac (patch)
tree16411ff17f1f08d723fbad459e90370964e7c0d5 /Modules
parent16d49680b56e00c53c00683b949138e584669fd3 (diff)
downloadcpython-c932f7284977ebf813313157c52d716ba225a7ac.zip
cpython-c932f7284977ebf813313157c52d716ba225a7ac.tar.gz
cpython-c932f7284977ebf813313157c52d716ba225a7ac.tar.bz2
gh-105375: Improve _decimal error handling (#105605)
Fix a bug where an exception could end up being overwritten.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_decimal/_decimal.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index c8ff389..73df3f3 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -3611,9 +3611,13 @@ dec_as_integer_ratio(PyObject *self, PyObject *args UNUSED)
goto error;
}
Py_SETREF(numerator, _py_long_floor_divide(numerator, tmp));
+ if (numerator == NULL) {
+ Py_DECREF(tmp);
+ goto error;
+ }
Py_SETREF(denominator, _py_long_floor_divide(denominator, tmp));
Py_DECREF(tmp);
- if (numerator == NULL || denominator == NULL) {
+ if (denominator == NULL) {
goto error;
}
}