Skip to content

Commit a12ccd9

Browse files
committed
Fix refleak in _BINARY_OP_INPLACE_ADD_UNICODE
PyStackRef_AsPyObjectSteal creates a new reference if the stackref is deferred. This reference is leaked if we deopt before the corresponding decref.
1 parent 293c317 commit a12ccd9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,8 @@ dummy_func(
732732
// At the end we just skip over the STORE_FAST.
733733
op(_BINARY_OP_INPLACE_ADD_UNICODE, (left, right --)) {
734734
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
735-
PyObject *right_o = PyStackRef_AsPyObjectSteal(right);
736735
assert(PyUnicode_CheckExact(left_o));
737-
assert(PyUnicode_CheckExact(right_o));
736+
assert(PyUnicode_CheckExact(PyStackRef_AsPyObjectBorrow(right)));
738737

739738
int next_oparg;
740739
#if TIER_ONE
@@ -761,6 +760,7 @@ dummy_func(
761760
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
762761
DEAD(left);
763762
PyObject *temp = PyStackRef_AsPyObjectSteal(*target_local);
763+
PyObject *right_o = PyStackRef_AsPyObjectSteal(right);
764764
PyUnicode_Append(&temp, right_o);
765765
*target_local = PyStackRef_FromPyObjectSteal(temp);
766766
Py_DECREF(right_o);

Python/executor_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)