Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 925ca76

Browse files
author
Victor Stinner
committed
Merged revisions 78636 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ................ r78636 | victor.stinner | 2010-03-03 22:56:53 +0100 (mer., 03 mars 2010) | 12 lines Merged revisions 78635 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r78635 | victor.stinner | 2010-03-03 22:53:41 +0100 (mer., 03 mars 2010) | 5 lines Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL() by Py_DECREF() to avoid a crash in pydebug mode. Use po->wo==NULL to detect than the panel is in the lop list or not. ........ ................
1 parent 1ff0c6c commit 925ca76

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Modules/_curses_panel.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,24 @@ PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo)
178178
po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type);
179179
if (po == NULL) return NULL;
180180
po->pan = pan;
181-
po->wo = wo;
182-
Py_INCREF(wo);
183181
if (insert_lop(po) < 0) {
184-
PyObject_DEL(po);
182+
po->wo = NULL;
183+
Py_DECREF(po);
185184
return NULL;
186185
}
186+
po->wo = wo;
187+
Py_INCREF(wo);
187188
return (PyObject *)po;
188189
}
189190

190191
static void
191192
PyCursesPanel_Dealloc(PyCursesPanelObject *po)
192193
{
193194
(void)del_panel(po->pan);
194-
Py_DECREF(po->wo);
195-
remove_lop(po);
195+
if (po->wo != NULL) {
196+
Py_DECREF(po->wo);
197+
remove_lop(po);
198+
}
196199
PyObject_DEL(po);
197200
}
198201

0 commit comments

Comments
 (0)