mirror of https://github.com/python/cpython.git
#6243: fix segfault when keyname() returns a NULL pointer.
Bug noted by Trundle, patched by Trundle and Jerry Chen.
This commit is contained in:
parent
a9a7611fb6
commit
b49e53ee16
|
@ -257,6 +257,10 @@ def test_resize_term(stdscr):
|
||||||
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
|
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
|
||||||
raise RuntimeError, "Expected resizeterm to update LINES and COLS"
|
raise RuntimeError, "Expected resizeterm to update LINES and COLS"
|
||||||
|
|
||||||
|
def test_issue6243(stdscr):
|
||||||
|
curses.ungetch(1025)
|
||||||
|
stdscr.getkey()
|
||||||
|
|
||||||
def main(stdscr):
|
def main(stdscr):
|
||||||
curses.savetty()
|
curses.savetty()
|
||||||
try:
|
try:
|
||||||
|
@ -264,6 +268,7 @@ def main(stdscr):
|
||||||
window_funcs(stdscr)
|
window_funcs(stdscr)
|
||||||
test_userptr_without_set(stdscr)
|
test_userptr_without_set(stdscr)
|
||||||
test_resize_term(stdscr)
|
test_resize_term(stdscr)
|
||||||
|
test_issue6243(stdscr)
|
||||||
finally:
|
finally:
|
||||||
curses.resetty()
|
curses.resetty()
|
||||||
|
|
||||||
|
|
|
@ -882,14 +882,17 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
|
||||||
/* getch() returns ERR in nodelay mode */
|
/* getch() returns ERR in nodelay mode */
|
||||||
PyErr_SetString(PyCursesError, "no input");
|
PyErr_SetString(PyCursesError, "no input");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (rtn<=255)
|
} else if (rtn<=255) {
|
||||||
return Py_BuildValue("c", rtn);
|
return Py_BuildValue("c", rtn);
|
||||||
else
|
} else {
|
||||||
|
const char *knp;
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
return PyString_FromString(unctrl(rtn));
|
knp = unctrl(rtn);
|
||||||
#else
|
#else
|
||||||
return PyString_FromString((char *)keyname(rtn));
|
knp = keyname(rtn);
|
||||||
#endif
|
#endif
|
||||||
|
return PyString_FromString((knp == NULL) ? "" : knp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
Loading…
Reference in New Issue