diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-03-14 10:45:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-14 10:45:32 (GMT) |
commit | 5208b4b37953a406db0ed6a9db545c2948dde989 (patch) | |
tree | 249b714d2e6476f7aced7368ad4bb18c929a13f3 /Modules | |
parent | 3a8c56295d6272ad2177d2de8af4c3f824f3ef92 (diff) | |
download | cpython-5208b4b37953a406db0ed6a9db545c2948dde989.zip cpython-5208b4b37953a406db0ed6a9db545c2948dde989.tar.gz cpython-5208b4b37953a406db0ed6a9db545c2948dde989.tar.bz2 |
bpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)
In math_2(), the first PyFloat_AsDouble() call should be checked
for failure before the second call.
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/mathmodule.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 77e325c..2a73a98 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1106,9 +1106,13 @@ math_2(PyObject *const *args, Py_ssize_t nargs, if (!_PyArg_CheckPositional(funcname, nargs, 2, 2)) return NULL; x = PyFloat_AsDouble(args[0]); + if (x == -1.0 && PyErr_Occurred()) { + return NULL; + } y = PyFloat_AsDouble(args[1]); - if ((x == -1.0 || y == -1.0) && PyErr_Occurred()) + if (y == -1.0 && PyErr_Occurred()) { return NULL; + } errno = 0; r = (*func)(x, y); if (Py_IS_NAN(r)) { |