Skip to content

Commit

Permalink
Fix scoping key
Browse files Browse the repository at this point in the history
The previous logic would add the size of the pointer target to the pointer value, which might point to another pointer being used as a scope key. Now, we increment the value as an integer instead, which means it can never be a valid pointer.
  • Loading branch information
JelleZijlstra committed May 3, 2024
1 parent b3f053c commit 8c3e0b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params)
seen_default = true;
expr_ty default_ = typeparam->v.TypeVar.default_value;
if (compiler_type_param_bound_or_default(c, default_, typeparam->v.TypeVar.name,
(void *)(typeparam + 1), false) < 0) {
(void *)((uintptr_t)typeparam + 1), false) < 0) {
return ERROR;
}
ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_TYPEPARAM_DEFAULT);
Expand Down
2 changes: 1 addition & 1 deletion Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,7 @@ symtable_visit_type_param(struct symtable *st, type_param_ty tp)
VISIT_QUIT(st, 0);
}
if (!symtable_visit_type_param_bound_or_default(st, tp->v.TypeVar.default_value, tp->v.TypeVar.name,
(void *)(tp + 1))) {
(void *)((uintptr_t)tp + 1))) {
VISIT_QUIT(st, 0);
}
break;
Expand Down

0 comments on commit 8c3e0b4

Please sign in to comment.