You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use-after-free for a window created inside curses.screen.use() #155864
screen.use() makes its screen current for the callback, but a window created there records the screen that was current before the call. The window therefore does not keep its own screen alive, and that screen can be freed while the window is still in use.
importcurses, gc, ptyA=curses.newterm(None, pty.openpty()[1], pty.openpty()[1])
B=curses.newterm(None, pty.openpty()[1], pty.openpty()[1])
win=A.use(lambdas: curses.newwin(5, 5)) # a window on screen AdelA# A's only window is wingc.collect()
win.addstr(0, 0, "x")
Expected: the window keeps the screen it belongs to alive. Doc/library/curses.rst says "Each window keeps its screen alive, so a screen remains valid as long as any of its windows does".
@fedonman@serhiy-storchaka,
the PR linked to this issue is merged and has no backport labels, i think this issue can be closed now as completed.
Is anything else left to address in this issue ?
Activity
gh-155864: Keep the module's current screen in step with use_screen() (…
BHUVANSH855 commentedon Aug 17, 2026
@fedonman @serhiy-storchaka,
the PR linked to this issue is merged and has no backport labels, i think this issue can be closed now as completed.
Is anything else left to address in this issue ?