[Python-checkins] r75066 - in python/trunk: Lib/test/test_curses.py Modules/_cursesmodule.c
andrew.kuchling
python-checkins at python.org
Sat Sep 26 00:23:54 CEST 2009
Author: andrew.kuchling
Date: Sat Sep 26 00:23:54 2009
New Revision: 75066
Log:
#6243: fix segfault when keyname() returns a NULL pointer.
Bug noted by Trundle, patched by Trundle and Jerry Chen.
Modified:
python/trunk/Lib/test/test_curses.py
python/trunk/Modules/_cursesmodule.c
Modified: python/trunk/Lib/test/test_curses.py
==============================================================================
--- python/trunk/Lib/test/test_curses.py (original)
+++ python/trunk/Lib/test/test_curses.py Sat Sep 26 00:23:54 2009
@@ -257,6 +257,10 @@
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:
@@ -264,6 +268,7 @@
window_funcs(stdscr)
test_userptr_without_set(stdscr)
test_resize_term(stdscr)
+ test_issue6243(stdscr)
finally:
curses.resetty()
Modified: python/trunk/Modules/_cursesmodule.c
==============================================================================
--- python/trunk/Modules/_cursesmodule.c (original)
+++ python/trunk/Modules/_cursesmodule.c Sat Sep 26 00:23:54 2009
@@ -882,14 +882,17 @@
/* 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 PyString_FromString(unctrl(rtn));
+ knp = unctrl(rtn);
#else
- return PyString_FromString((char *)keyname(rtn));
+ knp = keyname(rtn);
#endif
+ return PyString_FromString((knp == NULL) ? "" : knp);
+ }
}
static PyObject *
More information about the Python-checkins
mailing list