bpo-41604: Don't decrement the reference count of the previous user_ptr when set_panel_usertpr fails (GH-21933)

https://github.com/python/cpython/commit/3243e8a4b4b4cf321f9b28335d565742a34... commit: 3243e8a4b4b4cf321f9b28335d565742a34b1976 branch: master author: Anonymous Maarten <madebr@users.noreply.github.com> committer: serhiy-storchaka <storchaka@gmail.com> date: 2021-01-31T19:55:15+02:00 summary: bpo-41604: Don't decrement the reference count of the previous user_ptr when set_panel_usertpr fails (GH-21933) files: A Misc/NEWS.d/next/Library/2020-08-21-15-24-14.bpo-41604.rTXleO.rst M Modules/_curses_panel.c diff --git a/Misc/NEWS.d/next/Library/2020-08-21-15-24-14.bpo-41604.rTXleO.rst b/Misc/NEWS.d/next/Library/2020-08-21-15-24-14.bpo-41604.rTXleO.rst new file mode 100644 index 0000000000000..0f9794cbdb321 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-08-21-15-24-14.bpo-41604.rTXleO.rst @@ -0,0 +1,2 @@ +Don't decrement the reference count of the previous user_ptr when +set_panel_userptr fails. diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index d782ccd086798..94caf8c93bc8c 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -456,7 +456,9 @@ _curses_panel_panel_set_userptr_impl(PyCursesPanelObject *self, /* In case of an ncurses error, decref the new object again */ Py_DECREF(obj); } - Py_XDECREF(oldobj); + else { + Py_XDECREF(oldobj); + } _curses_panel_state *state = PyType_GetModuleState(cls); return PyCursesCheckERR(state, rc, "set_panel_userptr");
participants (1)
-
serhiy-storchaka