diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-06-16 18:01:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-16 18:01:15 (GMT) |
commit | 2beab5bdef5fa2a00a59371e6137f769586b7404 (patch) | |
tree | 8c515dfdb7f35a539fc179cbfb1002dbda8d3ee6 /Python | |
parent | b356a4749acb3e6f8c50e8abeb7b2d2b267738d7 (diff) | |
download | cpython-2beab5bdef5fa2a00a59371e6137f769586b7404.zip cpython-2beab5bdef5fa2a00a59371e6137f769586b7404.tar.gz cpython-2beab5bdef5fa2a00a59371e6137f769586b7404.tar.bz2 |
GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105847)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/specialize.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index cff414a..44b14c5 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1647,9 +1647,9 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs, } int argcount = code->co_argcount; int defcount = func->func_defaults == NULL ? 0 : (int)PyTuple_GET_SIZE(func->func_defaults); - assert(defcount <= argcount); int min_args = argcount-defcount; - if (nargs > argcount || nargs < min_args) { + // GH-105840: min_args is negative when somebody sets too many __defaults__! + if (min_args < 0 || nargs > argcount || nargs < min_args) { SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS); return -1; } |