gh-113297: Fix segfault in compiler for with statement with 19 context managers (#113327)

This commit is contained in:
Irit Katriel
2023-12-22 01:50:26 +00:00
committed by GitHub
parent 9afb0e1606
commit c31943af16
3 changed files with 29 additions and 1 deletions

View File

@@ -648,7 +648,7 @@ mark_except_handlers(basicblock *entryblock) {
struct _PyCfgExceptStack {
basicblock *handlers[CO_MAXBLOCKS+1];
basicblock *handlers[CO_MAXBLOCKS+2];
int depth;
};
@@ -661,6 +661,7 @@ push_except_block(struct _PyCfgExceptStack *stack, cfg_instr *setup) {
if (opcode == SETUP_WITH || opcode == SETUP_CLEANUP) {
target->b_preserve_lasti = 1;
}
assert(stack->depth <= CO_MAXBLOCKS);
stack->handlers[++stack->depth] = target;
return target;
}