GH-106008: Fix refleak when peepholing None comparisons (#106367)

This commit is contained in:
Brandt Bucher 2023-07-04 03:03:57 -07:00 committed by GitHub
parent c9ce983ae1
commit e4ba71fe4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1,2 @@
Fix possible reference leaks when failing to optimize comparisons with
:const:`None` in the bytecode compiler.

View 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;
}