Skip to content

Commit cd0225d

Browse files
committed
make sure we always emit something to jump to at the end
1 parent 84f5a9d commit cd0225d

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Python/compile.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8689,15 +8689,9 @@ prepare_localsplus(struct compiler* c, cfg_builder *g, int code_flags)
86898689
static int
86908690
add_return_at_end(struct compiler *c, int addNone)
86918691
{
8692-
/* Make sure every instruction stream that falls off the end returns None. */
8693-
instr_sequence *is = INSTR_STREAM(c);
8694-
if (is->s_used > 0) {
8695-
instruction *instr = &is->s_instrs[is->s_used];
8696-
int opcode = instr->i_opcode;
8697-
if (opcode == RETURN_VALUE || opcode == RETURN_CONST) {
8698-
return SUCCESS;
8699-
}
8700-
}
8692+
/* Make sure every instruction stream that falls off the end returns None.
8693+
* This also ensures that no jump target offsets are out of bounds.
8694+
*/
87018695
if (addNone) {
87028696
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
87038697
}

0 commit comments

Comments
 (0)