| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…erm() When initscr() was called while a screen from newterm() was current, it returned a window created with no screen. The window therefore did not hold a reference to the screen it belonged to, so the screen could be collected while the window was still in use, and the next method call on the window read freed memory. It now passes the current screen, like newwin(), newpad() and getwin() already do. That is NULL for the screen created by initscr(), which has no screen object, so that case is unchanged.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
And this is right. Please add a test for this case. |
Sorry, something went wrong.
The test now checks the identity the review asked for. The NEWS entry goes away because set_term(), newterm() and this code path are all new in 3.16 and unreleased, so no user could observe the crash.
There was a problem hiding this comment.
LGTM. 👍
Sorry, something went wrong.
…() (pythonGH-154752) initscr() called while a newterm() screen is current returned a second window object over that screen's standard window, with no reference to the screen. Either wrapper could then free the window used by the other. Return the screen's own standard window instead.
| Back | FazBrowse Home | New Git URL |
curses.initscr() called while a screen from curses.newterm() was current returned a
window built with no screen. The window's screen field is the reference that keeps a
screen alive, so this window kept nothing alive. Dropping the screen freed its WINDOW,
and the next method call on the window read freed memory:
When the current screen came from newterm(), initscr() now returns that screen's own
standard window, so there is only ever one wrapper over that WINDOW and it holds the
screen. Otherwise it passes state->topscreen, matching newwin(), newpad() and
getwin(); that value is NULL for the screen created by initscr(), which has no screen
object, so plain initscr() use is unchanged.
This restores what the screen objects documentation promises: "Each window keeps its screen
alive, so a screen remains valid as long as any of its windows does."
newterm() and set_term() are new in 3.16 (gh-90092, GH-151748), so no released version
is affected and there is no NEWS entry.
The reproducer above now prints no crash and exits 0, and
curses.initscr() is screen.stdscr is True where it was False. Tests: