]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151112: Fix double free in `assemble_init` when out of memory (#151142)
authorStan Ulbrych <stan@python.org>
Tue, 9 Jun 2026 19:45:54 +0000 (20:45 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2026 19:45:54 +0000 (20:45 +0100)
Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-12-24-35.gh-issue-151112.4RKCkD.rst [new file with mode: 0644]
Python/assemble.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-12-24-35.gh-issue-151112.4RKCkD.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-12-24-35.gh-issue-151112.4RKCkD.rst
new file mode 100644 (file)
index 0000000..93ee5c8
--- /dev/null
@@ -0,0 +1 @@
+Fix a crash in the compiler that could occur when running out of memory.
index 3df959c363419513105305d27e17b18a79ad8216..8bcb4c7bf3a9aa4e958d15ba35733dec6ab68021 100644 (file)
@@ -80,9 +80,9 @@ assemble_init(struct assembler *a, int firstlineno)
     }
     return SUCCESS;
 error:
-    Py_XDECREF(a->a_bytecode);
-    Py_XDECREF(a->a_linetable);
-    Py_XDECREF(a->a_except_table);
+    Py_CLEAR(a->a_bytecode);
+    Py_CLEAR(a->a_linetable);
+    Py_CLEAR(a->a_except_table);
     return ERROR;
 }