Skip to content

[3.13] bpo-44172: Keep reference to original window in curses subwindow objects (GH-26226) #133370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

serhiy-storchaka
Copy link
Member

The X/Open curses specification[0] and ncurses documentation[1] both state that subwindows must be deleted before the main window.

Deleting the windows in the wrong order causes a double-free with NetBSD's curses implementation.

To fix this, keep track of the original window object in the subwindow object, and keep a reference to the original for the lifetime of the subwindow.

[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html [1] https://invisible-island.net/ncurses/man/curs_window.3x.html (cherry picked from commit 0af61fe)

…ow objects (pythonGH-26226)

The X/Open curses specification[0] and ncurses documentation[1]
both state that subwindows must be deleted before the main window.

Deleting the windows in the wrong order causes a double-free with
NetBSD's curses implementation.

To fix this, keep track of the original window object in the subwindow
object, and keep a reference to the original for the lifetime of
the subwindow.

[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html
[1] https://invisible-island.net/ncurses/man/curs_window.3x.html
(cherry picked from commit 0af61fe)

Co-authored-by: Michael Forney <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) May 4, 2025 10:52
@serhiy-storchaka serhiy-storchaka merged commit 3c9d177 into python:3.13 May 4, 2025
38 checks passed
@serhiy-storchaka serhiy-storchaka deleted the backport-0af61fe-3.13 branch May 4, 2025 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants