Skip to content
7 changes: 7 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,13 @@ def test_resizeterm(self):
self.assertEqual(curses.LINES, lines)
self.assertEqual(curses.COLS, cols)

with self.assertRaises(OverflowError):
curses.resizeterm(35000, 1)

# GH-120378: Overflow failure in resizeterm() causes refresh to fail
tmp = curses.initscr()
tmp.erase()

def test_ungetch(self):
curses.ungetch(b'A')
self.assertEqual(self.stdscr.getkey(), 'A')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash related to integer overflow in :func:`curses.resizeterm`
8 changes: 4 additions & 4 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4113,9 +4113,9 @@ NoArgNoReturnFunctionBody(resetty)
/*[clinic input]
_curses.resizeterm

nlines: int
nlines: short
Height.
ncols: int
ncols: short
Width.
/

Expand All @@ -4126,8 +4126,8 @@ window dimensions (in particular the SIGWINCH handler).
[clinic start generated code]*/

static PyObject *
_curses_resizeterm_impl(PyObject *module, int nlines, int ncols)
/*[clinic end generated code: output=56d6bcc5194ad055 input=0fca02ebad5ffa82]*/
_curses_resizeterm_impl(PyObject *module, short nlines, short ncols)
/*[clinic end generated code: output=4de3abab50c67f02 input=414e92a63e3e9899]*/
{
PyObject *result;

Expand Down
50 changes: 40 additions & 10 deletions Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading