diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-06-11 10:06:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-11 10:06:06 (GMT) |
commit | c932f7284977ebf813313157c52d716ba225a7ac (patch) | |
tree | 16411ff17f1f08d723fbad459e90370964e7c0d5 /Modules | |
parent | 16d49680b56e00c53c00683b949138e584669fd3 (diff) | |
download | cpython-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.c | 6 |
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; } } |