Skip to content

Commit 931263b

Browse files
[3.9] bpo-41604: Don't decrement the reference count of the previous user_ptr when set_panel_usertpr fails (GH-21933). (GH-24403)
(cherry picked from commit 3243e8a) Co-authored-by: Anonymous Maarten <[email protected]> (cherry picked from commit 3c8d693) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 7ca947e commit 931263b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Don't decrement the reference count of the previous user_ptr when
2+
set_panel_userptr fails.

Modules/_curses_panel.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ _curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyObject *obj)
433433
/* In case of an ncurses error, decref the new object again */
434434
Py_DECREF(obj);
435435
}
436-
Py_XDECREF(oldobj);
436+
else {
437+
Py_XDECREF(oldobj);
438+
}
437439
return PyCursesCheckERR(rc, "set_panel_userptr");
438440
}
439441

0 commit comments

Comments
 (0)