gh-144067: Fix memory leak when initscr() follows setupterm()#144076
gh-144067: Fix memory leak when initscr() follows setupterm()#144076VanshAgarwal24036 wants to merge 3 commits intopython:mainfrom
Conversation
picnixz
left a comment
There was a problem hiding this comment.
The change is incorrect as we do not know how cur_win is being used. I believe we should fix it differently but we need discussion.
Again, stop opening PRs if it has not yet been triaged. It wastes reviewer's time.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Calling setupterm() before initscr() can leak memory: setupterm()
allocates the global ncurses cur_term, and initscr() internally
reinitializes the terminal (via newterm()) without freeing the
existing cur_term.
This change frees an existing cur_term before calling initscr(),
preventing the leak observed under ASAN.
Note: the _curses module is not available on Windows, so this change
was not runtime-tested locally. The fix is minimal and follows the
ncurses API’s ownership rules; Linux/macOS CI should cover the affected
code path.