diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-03 21:53:41 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-03 21:53:41 (GMT) |
commit | 2379bb664ac33b77d076a9a8db59f73af9eb3c8f (patch) | |
tree | a7425adce99d67bd8aabd03dab1e7d9f10d64067 | |
parent | ac80c157c74cf95e89fb74d7b3ba47b07846b2c2 (diff) | |
download | cpython-2379bb664ac33b77d076a9a8db59f73af9eb3c8f.zip cpython-2379bb664ac33b77d076a9a8db59f73af9eb3c8f.tar.gz cpython-2379bb664ac33b77d076a9a8db59f73af9eb3c8f.tar.bz2 |
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.
-rw-r--r-- | Modules/_curses_panel.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 6831473..74e6bfa 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); } |