]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40048: Fix _PyCode_InitOpcache() error path (GH-19691)
authorVictor Stinner <vstinner@python.org>
Fri, 24 Apr 2020 00:43:18 +0000 (02:43 +0200)
committerGitHub <noreply@github.com>
Fri, 24 Apr 2020 00:43:18 +0000 (02:43 +0200)
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.

Python/ceval.c

index 59765d850ba1dbee066e522c130bd14c49a53441..c610419f24f58067be23b25bda2007101fdcf59e 100644 (file)
@@ -1297,7 +1297,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, 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 +=