From e05186a74d3fa1f83dfafa1719b10d4b992ba677 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 3 Jul 2023 11:36:15 -0700 Subject: [PATCH 1/2] Fix refleak when peepholing branches on None --- Python/flowgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 213c993bb863a3..e159a4356dfe46 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; } From d5afb7c043cbcafc0f9b49193398685eb83e8103 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 3 Jul 2023 11:38:53 -0700 Subject: [PATCH 2/2] blurb add --- .../2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-07-03-11-38-43.gh-issue-106008.HDf1zd.rst 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 00000000000000..a57b892fd53242 --- /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.