Skip to content

Commit ede1ff2

Browse files
bpo-43108: Fix a reference leak in the curses module (GH-24420) (GH-24429)
(cherry picked from commit bb739ec) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 parent e3110c3 commit ede1ff2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a reference leak in the :mod:`curses` module. Patch by Pablo Galindo

Modules/_cursesmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
365365
*bytes = obj;
366366
/* check for embedded null bytes */
367367
if (PyBytes_AsStringAndSize(*bytes, &str, NULL) < 0) {
368+
Py_DECREF(obj);
368369
return 0;
369370
}
370371
return 1;
@@ -679,8 +680,9 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
679680
#else
680681
strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL);
681682
#endif
682-
if (strtype == 0)
683+
if (strtype == 0) {
683684
return NULL;
685+
}
684686
if (use_attr) {
685687
attr_old = getattrs(self->win);
686688
(void)wattrset(self->win,attr);

0 commit comments

Comments
 (0)