summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAndrew Kuchling <amk@amk.ca>2013-06-22 18:50:56 (GMT)
committerAndrew Kuchling <amk@amk.ca>2013-06-22 18:50:56 (GMT)
commit9290dd14b02508a667165d2e98f3f99aad61764e (patch)
treee17a24c10d220b6e3013ec00ebbe44aaf8efe75b /Lib/test
parent45d9493ee9f91dcdf2bafdf67f3d5adc432848bf (diff)
downloadcpython-9290dd14b02508a667165d2e98f3f99aad61764e.zip
cpython-9290dd14b02508a667165d2e98f3f99aad61764e.tar.gz
cpython-9290dd14b02508a667165d2e98f3f99aad61764e.tar.bz2
#18113: avoid segfault if Py_XDECREF triggers code that calls set_panel_userptr again
Problem noted & original patch by Serhiy Storchaka; I tweaked the patch a bit.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_curses.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index 76812b7..7310afc 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -264,6 +264,14 @@ def test_userptr_memory_leak(stdscr):
if sys.getrefcount(obj) != nrefs:
raise RuntimeError("set_userptr leaked references")
+def test_userptr_segfault(stdscr):
+ panel = curses.panel.new_panel(stdscr)
+ class A:
+ def __del__(self):
+ panel.set_userptr(None)
+ panel.set_userptr(A())
+ panel.set_userptr(None)
+
def test_resize_term(stdscr):
if hasattr(curses, 'resizeterm'):
lines, cols = curses.LINES, curses.COLS
@@ -330,6 +338,7 @@ def main(stdscr):
window_funcs(stdscr)
test_userptr_without_set(stdscr)
test_userptr_memory_leak(stdscr)
+ test_userptr_segfault(stdscr)
test_resize_term(stdscr)
test_issue6243(stdscr)
test_unget_wch(stdscr)