bpo-43108: Fix a reference leak in the curses module (GH-24420)

(cherry picked from commit bb739ec922)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-02-03 05:41:09 -08:00 committed by GitHub
parent f02ef7afcf
commit 12bfc595c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1 @@
Fixed a reference leak in the :mod:`curses` module. Patch by Pablo Galindo

View file

@ -365,6 +365,7 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
*bytes = obj;
/* check for embedded null bytes */
if (PyBytes_AsStringAndSize(*bytes, &str, NULL) < 0) {
Py_DECREF(obj);
return 0;
}
return 1;
@ -679,8 +680,9 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
#else
strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL);
#endif
if (strtype == 0)
if (strtype == 0) {
return NULL;
}
if (use_attr) {
attr_old = getattrs(self->win);
(void)wattrset(self->win,attr);