aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2023-07-04 03:03:57 -0700
committerGitHub <noreply@github.com>2023-07-04 11:03:57 +0100
commite4ba71fe4b32ae0d7fb3319d697616470fba1e58 (patch)
tree0610612b46d26fe62b30cc07d30c80cf6aa57224
parentc9ce983ae1a361f431a0303aeb6f4b8e1d674275 (diff)
downloadcpython-e4ba71fe4b32ae0d7fb3319d697616470fba1e58.tar.gz
cpython-e4ba71fe4b32ae0d7fb3319d697616470fba1e58.zip
GH-106008: Fix refleak when peepholing `None` comparisons (#106367)
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst2
-rw-r--r--Python/flowgraph.c2
2 files changed, 3 insertions, 1 deletions
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
index 00000000000..a57b892fd53
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst
@@ -0,0 +1,2 @@
+Fix possible reference leaks when failing to optimize comparisons with
+:const:`None` in the bytecode compiler.
diff --git a/Python/flowgraph.c b/Python/flowgraph.c
index 213c993bb86..e159a4356df 100644
--- a/Python/flowgraph.c
+++ b/Python/flowgraph.c
@@ -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;
}