From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:26:39 +0000 (+0100) Subject: [3.13] Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject (GH... X-Git-Tag: v3.13.2~189 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=367ea893847439502e155708539917bf655beb40;p=thirdparty%2FPython%2Fcpython.git [3.13] Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject (GH-128006) Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject (GH-127910) After commit 10a91d7e9 introduced arena cleanup, commit 2dfbd4f36 removed the free call when _PyCompile_AstOptimize fails. (cherry picked from commit cfeaa992ba9bad9be2687afcafd85156703d74e8) Co-authored-by: Berker Peksag --- diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 5891d50cd3f5..f9daf8168f1c 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1485,6 +1485,7 @@ Py_CompileStringObject(const char *str, PyObject *filename, int start, if (flags && (flags->cf_flags & PyCF_ONLY_AST)) { if ((flags->cf_flags & PyCF_OPTIMIZED_AST) == PyCF_OPTIMIZED_AST) { if (_PyCompile_AstOptimize(mod, filename, flags, optimize, arena) < 0) { + _PyArena_Free(arena); return NULL; } }