Skip to content

Commit 889a321

Browse files
committed
Drop the user pointer reference after unlinking it in tp_clear
PyCursesPanel_Clear() released the user pointer before clearing it from the panel, leaving the panel pointing at an object whose refcount could reach zero. Same ordering as the deallocator.
1 parent 44ab80b commit 889a321

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/_curses_panel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,11 @@ PyCursesPanel_Clear(PyObject *op)
437437
PyCursesPanelObject *self = _PyCursesPanelObject_CAST(op);
438438
PyObject *extra = (PyObject *)panel_userptr(self->pan);
439439
if (extra != NULL) {
440-
Py_DECREF(extra);
441440
if (set_panel_userptr(self->pan, NULL) == ERR) {
442441
curses_panel_panel_set_error(self, "set_panel_userptr", NULL);
443442
return -1;
444443
}
444+
Py_DECREF(extra);
445445
}
446446
// self->wo should not be cleared because an associated WINDOW may exist
447447
return 0;

0 commit comments

Comments
 (0)