diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-11 10:55:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-11 10:55:18 (GMT) |
commit | b4b5565e4779d81c943bffe22ffe0972fa398702 (patch) | |
tree | dd127b7dc852152ace97110a3d39faa76aa832de /Modules | |
parent | 36ecbc3570120c55d89eb8695b16525d6e77b454 (diff) | |
download | cpython-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.c | 6 |
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; } } |