Skip to content
Closed
Changes from all commits
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
gh-123913: Fix NULL handling in _curses_initscr_impl of `_cursesm…
…odule`
  • Loading branch information
sobolevn committed Sep 10, 2024
commit c5e0c5598453cedece3fac212a519e5c0c185f37
10 changes: 6 additions & 4 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3266,7 +3266,6 @@ _curses_initscr_impl(PyObject *module)
/*[clinic end generated code: output=619fb68443810b7b input=514f4bce1821f6b5]*/
{
WINDOW *win;
PyCursesWindowObject *winobj;

if (initialised) {
wrefresh(stdscr);
Expand Down Expand Up @@ -3362,9 +3361,12 @@ _curses_initscr_impl(PyObject *module)
SetDictInt("LINES", LINES);
SetDictInt("COLS", COLS);

winobj = (PyCursesWindowObject *)PyCursesWindow_New(win, NULL);
screen_encoding = winobj->encoding;
return (PyObject *)winobj;
PyObject *winobj = PyCursesWindow_New(win, NULL);
if (winobj == NULL) {
return NULL;
}
screen_encoding = ((PyCursesWindowObject *) winobj)->encoding;
return winobj;
}

/*[clinic input]
Expand Down