summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_curses_panel.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index 02e064f..ff1276d 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -178,12 +178,13 @@ PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo)
po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type);
if (po == NULL) return NULL;
po->pan = pan;
- po->wo = wo;
- Py_INCREF(wo);
if (insert_lop(po) < 0) {
- PyObject_DEL(po);
+ po->wo = NULL;
+ Py_DECREF(po);
return NULL;
}
+ po->wo = wo;
+ Py_INCREF(wo);
return (PyObject *)po;
}
@@ -191,8 +192,10 @@ static void
PyCursesPanel_Dealloc(PyCursesPanelObject *po)
{
(void)del_panel(po->pan);
- Py_DECREF(po->wo);
- remove_lop(po);
+ if (po->wo != NULL) {
+ Py_DECREF(po->wo);
+ remove_lop(po);
+ }
PyObject_DEL(po);
}