mirror of
https://github.com/python/cpython.git
synced 2025-12-05 00:52:25 +00:00
Bug #1400115, Fix segfault when calling curses.panel.userptr()
without prior setting of the userptr. Will backport.
This commit is contained in:
parent
e0aec6df5e
commit
5e3d862392
3 changed files with 19 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import curses, sys, tempfile, os
|
import curses, sys, tempfile, os
|
||||||
|
import curses.panel
|
||||||
|
|
||||||
# Optionally test curses module. This currently requires that the
|
# Optionally test curses module. This currently requires that the
|
||||||
# 'curses' resource be given on the regrtest command line using the -u
|
# 'curses' resource be given on the regrtest command line using the -u
|
||||||
|
|
@ -213,12 +214,22 @@ def unit_tests():
|
||||||
print 'curses.unctrl fails on character', repr(ch)
|
print 'curses.unctrl fails on character', repr(ch)
|
||||||
|
|
||||||
|
|
||||||
|
def test_userptr_without_set(stdscr):
|
||||||
|
w = curses.newwin(10, 10)
|
||||||
|
p = curses.panel.new_panel(w)
|
||||||
|
# try to access userptr() before calling set_userptr() -- segfaults
|
||||||
|
try:
|
||||||
|
p.userptr()
|
||||||
|
raise RuntimeError, 'userptr should fail since not set'
|
||||||
|
except curses.panel.error:
|
||||||
|
pass
|
||||||
|
|
||||||
def main(stdscr):
|
def main(stdscr):
|
||||||
curses.savetty()
|
curses.savetty()
|
||||||
try:
|
try:
|
||||||
module_funcs(stdscr)
|
module_funcs(stdscr)
|
||||||
window_funcs(stdscr)
|
window_funcs(stdscr)
|
||||||
|
test_userptr_without_set(stdscr)
|
||||||
finally:
|
finally:
|
||||||
curses.resetty()
|
curses.resetty()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,9 @@ Core and builtins
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Bug #1400115, Fix segfault when calling curses.panel.userptr()
|
||||||
|
without prior setting of the userptr.
|
||||||
|
|
||||||
- Fix 64-bit problems in bsddb.
|
- Fix 64-bit problems in bsddb.
|
||||||
|
|
||||||
- Patch #1365916: fix some unsafe 64-bit mmap methods.
|
- Patch #1365916: fix some unsafe 64-bit mmap methods.
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,11 @@ PyCursesPanel_userptr(PyCursesPanelObject *self)
|
||||||
PyObject *obj;
|
PyObject *obj;
|
||||||
PyCursesInitialised;
|
PyCursesInitialised;
|
||||||
obj = (PyObject *) panel_userptr(self->pan);
|
obj = (PyObject *) panel_userptr(self->pan);
|
||||||
|
if (obj == NULL) {
|
||||||
|
PyErr_SetString(PyCursesError, "no userptr set");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Py_INCREF(obj);
|
Py_INCREF(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue