Skip to content

Commit bad482d

Browse files
committed
bpo-43108: Fix a reference leak in the curses module
1 parent 58fb156 commit bad482d

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
@@ -388,6 +388,7 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
388388
*bytes = obj;
389389
/* check for embedded null bytes */
390390
if (PyBytes_AsStringAndSize(*bytes, &str, NULL) < 0) {
391+
Py_DECREF(obj);
391392
return 0;
392393
}
393394
return 1;
@@ -828,8 +829,9 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
828829
#else
829830
strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL);
830831
#endif
831-
if (strtype == 0)
832+
if (strtype == 0) {
832833
return NULL;
834+
}
833835
if (use_attr) {
834836
attr_old = getattrs(self->win);
835837
(void)wattrset(self->win,attr);

0 commit comments

Comments
 (0)