]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-106008: Fix refleak when peepholing `None` comparisons (#106367)
authorBrandt Bucher <brandtbucher@microsoft.com>
Tue, 4 Jul 2023 10:03:57 +0000 (03:03 -0700)
committerGitHub <noreply@github.com>
Tue, 4 Jul 2023 10:03:57 +0000 (11:03 +0100)
Misc/NEWS.d/next/Core and Builtins/2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst [new file with mode: 0644]
Python/flowgraph.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst b/Misc/NEWS.d/next/Core and Builtins/2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst
new file mode 100644 (file)
index 0000000..a57b892
--- /dev/null
@@ -0,0 +1,2 @@
+Fix possible reference leaks when failing to optimize comparisons with
+:const:`None` in the bytecode compiler.
index 213c993bb863a34ae23f8cf5d83096efcd3a49ab..e159a4356dfe4606501d6321b539bc6a4262030d 100644 (file)
@@ -1377,9 +1377,9 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
                             goto error;
                         }
                         if (!Py_IsNone(cnt)) {
+                            Py_DECREF(cnt);
                             break;
                         }
-                        Py_DECREF(cnt);
                         if (bb->b_iused <= i + 2) {
                             break;
                         }