[3.9] bpo-41604: Don't decrement the reference count of the previous user_ptr when set_panel_usertpr fails (GH-21933). (GH-24403)

(cherry picked from commit 3243e8a4b4)

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
This commit is contained in:
Serhiy Storchaka 2021-01-31 21:44:31 +02:00 committed by GitHub
parent e9d4960d15
commit 3c8d693443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,2 @@
Don't decrement the reference count of the previous user_ptr when
set_panel_userptr fails.

View File

@ -440,7 +440,9 @@ _curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyObject *obj)
/* In case of an ncurses error, decref the new object again */
Py_DECREF(obj);
}
Py_XDECREF(oldobj);
else {
Py_XDECREF(oldobj);
}
return PyCursesCheckERR(rc, "set_panel_userptr");
}