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
Fixes a use-after-free when curses.new_prescr() is followed by initscr() or newterm().
The pending pre-screen is now tracked by the curses module and its ownership is transferred when the screen is adopted, preventing the new_prescr() wrapper from deleting a live SCREEN.
The fix works for the reported case, but the ownership model is incomplete: the ncurses new_prescr() returns the same pending SCREEN on every call until initscr()/newterm() consumes it. So after pre1 = curses.new_prescr(); pre2 = curses.new_prescr() two objects own one screen; when pre1 is deleted it still calls delscreen() on it, pre2 keeps a dangling pointer, and the assertion in newterm() only holds if the next allocation reuses the address. new_prescr() should return the existing object while state->prescreen still owns a screen, so that exactly one object owns it.
new_prescr() is new in 3.16, so no NEWS entry is needed (skip news).
test_initscr_after_new_prescr_keeps_screen_alive calls initscr() on the real stdout; see how TestCurses.setUp() redirects it.
Thanks, the ownership is right now, and it is clean under -R 3:3.
One thing left: test_initscr_after_new_prescr_keeps_screen_alive still runs initscr() on the real stdout, so its escape sequences end up in the test output. Redirect fd 1 to a pty for the duration of the test:
Thanks, the ownership is right now, and it is clean under -R 3:3.
One thing left: test_initscr_after_new_prescr_keeps_screen_alive still runs initscr() on the real stdout, so its escape sequences end up in the test output. Redirect fd 1 to a pty for the duration of the test:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a use-after-free when
curses.new_prescr()is followed byinitscr()ornewterm().The pending pre-screen is now tracked by the curses module and its ownership is transferred when the screen is adopted, preventing the
new_prescr()wrapper from deleting a liveSCREEN.Fixes issue gh-155875