[Python-checkins] r78635 - python/trunk/Modules/_curses_panel.c

victor.stinner python-checkins at python.org
Wed Mar 3 22:53:42 CET 2010


Author: victor.stinner
Date: Wed Mar 3 22:53:41 2010
New Revision: 78635
Log:
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.
Modified:
 python/trunk/Modules/_curses_panel.c
Modified: python/trunk/Modules/_curses_panel.c
==============================================================================
--- python/trunk/Modules/_curses_panel.c	(original)
+++ python/trunk/Modules/_curses_panel.c	Wed Mar 3 22:53:41 2010
@@ -178,12 +178,13 @@
 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 @@
 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);
 }
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /