Skip to content

Conversation

@VanshAgarwal24036
Copy link
Contributor

@VanshAgarwal24036 VanshAgarwal24036 commented Jan 20, 2026

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.

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bedevere-app
Copy link

bedevere-app bot commented Jan 20, 2026

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants