]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-151112: Fix double free in `assemble_init` when out of memory (GH-151142...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 9 Jun 2026 20:13:40 +0000 (22:13 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2026 20:13:40 +0000 (21:13 +0100)
gh-151112: Fix double free in `assemble_init` when out of memory (GH-151142)
(cherry picked from commit 580499177ca91477b53b4a40afcec7d3370265b0)

Co-authored-by: Stan Ulbrych <stan@python.org>
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 35453277dd84d10ece150c1578368309b11f95db..288d786461b31d793611fad3739c84b5dcd43bd8 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;
 }