Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix refleak in _cursesmodule.c
  • Loading branch information
eendebakpt committed Mar 6, 2026
commit e4fa631adcccd4de1411d4345fa8213602a64946
3 changes: 3 additions & 0 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
attr_old = getattrs(self->win);
if (curses_wattrset(self, attr, "addstr") < 0) {
curses_release_wstr(strtype, wstr);
Py_DECREF(bytesobj);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful here. PyCurses_ConvertToString has a weird return type so you might not necessarily have bytesobj set to something (it might be in wstr instead).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

return NULL;
}
}
Expand Down Expand Up @@ -1210,6 +1211,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
attr_old = getattrs(self->win);
if (curses_wattrset(self, attr, "addnstr") < 0) {
curses_release_wstr(strtype, wstr);
Py_DECREF(bytesobj);
return NULL;
}
}
Expand Down Expand Up @@ -2212,6 +2214,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
attr_old = getattrs(self->win);
if (curses_wattrset(self, attr, "insstr") < 0) {
curses_release_wstr(strtype, wstr);
Py_DECREF(bytesobj);
return NULL;
}
}
Expand Down