Skip to content

Commit

Permalink
Fix an array index out-of-bound bug
Browse files Browse the repository at this point in the history
Variable `vararg` indicates the index of vararg in parameter list.
While copying kwargs to `buf`, the index `i` should not add `vararg`, which leads to an out-of-bound bug.

When there are positional args, vararg and keyword args in a function definition, in which case `vararg` > 1, this bug can be triggered.

e.g.
```
    pos: object
    *args: object
    kw: object
```
  • Loading branch information
colorfulappl committed Mar 24, 2022
1 parent 6793f38 commit 6203962
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Python/getargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,7 @@ _PyArg_UnpackKeywordsWithVararg(PyObject *const *args, Py_ssize_t nargs,
current_arg = NULL;
}

buf[i + vararg + 1] = current_arg;
buf[i + 1] = current_arg;

if (current_arg) {
--nkwargs;
Expand Down

0 comments on commit 6203962

Please sign in to comment.