Skip to content

Commit f224e20

Browse files
committed
Don't access last instruction of empty basicblocks
1 parent f32c419 commit f224e20

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Python/compile.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7801,10 +7801,12 @@ scan_block_for_local(int target, basicblock *b, bool unsafe_to_start,
78017801
if (b->b_next && !b->b_nofallthrough) {
78027802
MAYBE_PUSH(b->b_next);
78037803
}
7804-
struct instr *last = &b->b_instr[b->b_iused-1];
7805-
if (is_jump(last)) {
7806-
assert(last->i_target != NULL);
7807-
MAYBE_PUSH(last->i_target);
7804+
if (b->b_iused > 0) {
7805+
struct instr *last = &b->b_instr[b->b_iused-1];
7806+
if (is_jump(last)) {
7807+
assert(last->i_target != NULL);
7808+
MAYBE_PUSH(last->i_target);
7809+
}
78087810
}
78097811
}
78107812
}

0 commit comments

Comments
 (0)