Skip to content

gh-152503: Fix garbage text from curses wide-character cell reads#152505

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:curses-cchar-init
Open

gh-152503: Fix garbage text from curses wide-character cell reads#152505
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:curses-cchar-init

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

window.in_wch(), window.in_wchstr() and window.getbkgrnd() read a cell into an uninitialized cchar_t and rely on the curses library leaving the text NUL-terminated — which ncurses does but X/Open does not require, so libraries such as NetBSD curses returned uninitialized bytes as wide characters (surfacing as ValueError for out-of-range code points).

Zero-initialize the cell buffers before the read (in_wch, getbkgrnd, in_wchstr) and default the getcchar() output to an empty string, since getcchar() need not write the text of an empty cell.

No-op on ncurses; test_curses keeps passing and stays refleak-clean.

🤖 Generated with Claude Code

window.in_wch(), window.in_wchstr() and window.getbkgrnd() read a cell
into an uninitialized cchar_t, relying on the curses library to leave the
text NUL-terminated -- which ncurses does but X/Open does not require, so
some libraries (such as NetBSD curses) returned uninitialized bytes as
wide characters.  Zero-initialize the cell buffers before the read and
default the getcchar() output to an empty string.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant