bpo-40048: Fix _PyCode_InitOpcache() error path (GH-19691) (GH-19698)

If _PyCode_InitOpcache() fails in _PyEval_EvalFrameDefault(), use
"goto exit_eval_frame;" rather than "return NULL;" to exit the
function in a consistent state. For example, tstate->frame is now
reset properly.

(cherry picked from commit 25104949a5)
This commit is contained in:
Victor Stinner 2020-04-24 03:07:20 +02:00 committed by GitHub
parent 3340b2a61b
commit d9df63deab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1159,7 +1159,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
co->co_opcache_flag++;
if (co->co_opcache_flag == OPCACHE_MIN_RUNS) {
if (_PyCode_InitOpcache(co) < 0) {
return NULL;
goto exit_eval_frame;
}
#if OPCACHE_STATS
opcache_code_objects_extra_mem +=