summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-06-11 10:55:18 (GMT)
committerGitHub <noreply@github.com>2023-06-11 10:55:18 (GMT)
commitb4b5565e4779d81c943bffe22ffe0972fa398702 (patch)
treedd127b7dc852152ace97110a3d39faa76aa832de /Modules
parent36ecbc3570120c55d89eb8695b16525d6e77b454 (diff)
downloadcpython-b4b5565e4779d81c943bffe22ffe0972fa398702.zip
cpython-b4b5565e4779d81c943bffe22ffe0972fa398702.tar.gz
cpython-b4b5565e4779d81c943bffe22ffe0972fa398702.tar.bz2
[3.12] gh-105375: Improve _decimal error handling (GH-105605) (#105647)
Fix a bug where an exception could end up being overwritten. (cherry picked from commit c932f7284977ebf813313157c52d716ba225a7ac) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
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 0e11c87..0005081 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -3615,9 +3615,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;
}
}