diff options
author | Mark Shannon <mark@hotpy.org> | 2024-08-21 11:44:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 11:44:56 (GMT) |
commit | 1eba8bae9223600677dfa3a4ce8b7e4d2b8fd00d (patch) | |
tree | 90f3f920f8559e83452f974aa15e9485f1d250f8 /Python | |
parent | 90c892efeaae28bd849a01b42842f19dcd67b9f4 (diff) | |
download | cpython-1eba8bae9223600677dfa3a4ce8b7e4d2b8fd00d.zip cpython-1eba8bae9223600677dfa3a4ce8b7e4d2b8fd00d.tar.gz cpython-1eba8bae9223600677dfa3a4ce8b7e4d2b8fd00d.tar.bz2 |
GH-123185: Check for `NULL` after calling `_PyEvalFramePushAndInit` (GH-123194)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bytecodes.c | 6 | ||||
-rw-r--r-- | Python/executor_cases.c.h | 6 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index ec0f6ab..3edd374 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3584,8 +3584,12 @@ dummy_func( args[-1] = self; init_frame = _PyEvalFramePushAndInit( tstate, init_func, NULL, args-1, oparg+1, NULL, shim); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; SYNC_SP(); + if (init_frame == NULL) { + _PyEval_FrameClearAndPop(tstate, shim); + ERROR_NO_POP(); + } + frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; /* Account for pushing the extra frame. * We don't check recursion depth here, * as it will be checked after start_frame */ diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 9226b7a..1db8e50 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -4152,9 +4152,13 @@ args[-1] = self; init_frame = _PyEvalFramePushAndInit( tstate, init_func, NULL, args-1, oparg+1, NULL, shim); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; stack_pointer += -2 - oparg; assert(WITHIN_STACK_BOUNDS()); + if (init_frame == NULL) { + _PyEval_FrameClearAndPop(tstate, shim); + JUMP_TO_ERROR(); + } + frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; /* Account for pushing the extra frame. * We don't check recursion depth here, * as it will be checked after start_frame */ diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 27971ce..f4a5d2a 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1020,9 +1020,13 @@ args[-1] = self; init_frame = _PyEvalFramePushAndInit( tstate, init_func, NULL, args-1, oparg+1, NULL, shim); - frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; stack_pointer += -2 - oparg; assert(WITHIN_STACK_BOUNDS()); + if (init_frame == NULL) { + _PyEval_FrameClearAndPop(tstate, shim); + goto error; + } + frame->return_offset = 1 + INLINE_CACHE_ENTRIES_CALL; /* Account for pushing the extra frame. * We don't check recursion depth here, * as it will be checked after start_frame */ |