mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fix uninitialized memory read for cases like def(f, *): pass
There's not much interesting here. The old code read uninitialized memory but at worst incremented i past NCH(n), but no bad effects followed from that.
This commit is contained in:
parent
c3fee69464
commit
e921e02a2e
1 changed files with 11 additions and 5 deletions
14
Python/ast.c
14
Python/ast.c
|
@ -742,14 +742,20 @@ ast_for_arguments(struct compiling *c, const node *n)
|
||||||
}
|
}
|
||||||
assert(TYPE(n) == typedargslist || TYPE(n) == varargslist);
|
assert(TYPE(n) == typedargslist || TYPE(n) == varargslist);
|
||||||
|
|
||||||
/* first count the number of positional args & defaults */
|
/* First count the number of positional args & defaults. The
|
||||||
|
variable i is the loop index for this for loop and the next.
|
||||||
|
The next loop picks up where the first leaves off.
|
||||||
|
*/
|
||||||
for (i = 0; i < NCH(n); i++) {
|
for (i = 0; i < NCH(n); i++) {
|
||||||
ch = CHILD(n, i);
|
ch = CHILD(n, i);
|
||||||
if (TYPE(ch) == STAR) {
|
if (TYPE(ch) == STAR) {
|
||||||
/* skip star and possible argument */
|
/* skip star */
|
||||||
i++;
|
i++;
|
||||||
i += (TYPE(CHILD(n, i)) == tfpdef
|
if (i < NCH(n) && /* skip argument following star */
|
||||||
|| TYPE(CHILD(n, i)) == vfpdef);
|
(TYPE(CHILD(n, i)) == tfpdef ||
|
||||||
|
TYPE(CHILD(n, i)) == vfpdef)) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (TYPE(ch) == DOUBLESTAR) break;
|
if (TYPE(ch) == DOUBLESTAR) break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue