Issue #25745: Fixed leaking a userptr in curses panel destructor.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 8 May 2016 21:11:59 +0000 (00:11 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 8 May 2016 21:11:59 +0000 (00:11 +0300)
Misc/NEWS
Modules/_curses_panel.c

index f9bb8efbe0831b3cb767e795bb0a267dc89b0db5..d41910a92f3818f7747ed35e217d0ade55c7210f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -116,6 +116,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #25745: Fixed leaking a userptr in curses panel destructor.
+
 - Issue #26881: The modulefinder module now supports extended opcode arguments.
 
 - Issue #23815: Fixed crashes related to directly created instances of types in
index c77e614724e0022ea033c7c2aef61f4dffccbd70..228f4971ac372d445c40ea2e39e3bee6684f1906 100644 (file)
@@ -220,6 +220,11 @@ PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo)
 static void
 PyCursesPanel_Dealloc(PyCursesPanelObject *po)
 {
+    PyObject *obj = (PyObject *) panel_userptr(po->pan);
+    if (obj) {
+        (void)set_panel_userptr(po->pan, NULL);
+        Py_DECREF(obj);
+    }
     (void)del_panel(po->pan);
     if (po->wo != NULL) {
         Py_DECREF(po->wo);