diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-10-04 20:40:17 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-10-04 20:40:17 (GMT) |
commit | 7e2ef573ed48dce066a5dc0367bda4099614bc3a (patch) | |
tree | ec466ed691143921f274b1b2d222a515c63a571d | |
parent | 0df35a93a2c53debf6d3ce00f022b79ea7892429 (diff) | |
download | cpython-7e2ef573ed48dce066a5dc0367bda4099614bc3a.zip cpython-7e2ef573ed48dce066a5dc0367bda4099614bc3a.tar.gz cpython-7e2ef573ed48dce066a5dc0367bda4099614bc3a.tar.bz2 |
Merged revisions 75066 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75066 | andrew.kuchling | 2009-09-25 17:23:54 -0500 (Fri, 25 Sep 2009) | 4 lines
#6243: fix segfault when keyname() returns a NULL pointer.
Bug noted by Trundle, patched by Trundle and Jerry Chen.
........
-rw-r--r-- | Lib/test/test_curses.py | 5 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 4be2029..2615ffb 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -259,6 +259,10 @@ def test_resize_term(stdscr): if curses.LINES != lines - 1 or curses.COLS != cols + 1: raise RuntimeError("Expected resizeterm to update LINES and COLS") +def test_issue6243(stdscr): + curses.ungetch(1025) + stdscr.getkey() + def main(stdscr): curses.savetty() try: @@ -266,6 +270,7 @@ def main(stdscr): window_funcs(stdscr) test_userptr_without_set(stdscr) test_resize_term(stdscr) + test_issue6243(stdscr) finally: curses.resetty() diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index c7d3778..da19216 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -890,14 +890,17 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) /* getch() returns ERR in nodelay mode */ PyErr_SetString(PyCursesError, "no input"); return NULL; - } else if (rtn<=255) + } else if (rtn<=255) { return Py_BuildValue("C", rtn); - else + } else { + const char *knp; #if defined(__NetBSD__) - return PyUnicode_FromString(unctrl(rtn)); + knp = unctrl(rtn); #else - return PyUnicode_FromString((const char *)keyname(rtn)); + knp = keyname(rtn); #endif + return PyUnicode_FromString((knp == NULL) ? "" : knp); + } } static PyObject * |