Skip to content

gh-155877: Reject a NUL sharing a curses cell, keep a lone one - #156158

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:fix-155877-nul
Aug 21, 2026
Merged

gh-155877: Reject a NUL sharing a curses cell, keep a lone one#156158
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:fix-155877-nul

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 21, 2026

Copy link
Copy Markdown
Member

An alternative to #155878.

setcchar() takes a NUL-terminated string, so a NUL sharing a cell with other characters dropped the rest of the cell, and an empty cell read back as complexchar(''), which is not a valid constructor call.

Reject a NUL among other characters, read an empty cell as a NUL, as the narrow build already does, and give a NUL its own cell in complexstr().

A lone NUL stays a character: complexchar('\0') works and addch(complexchar('\0')) writes what addch(0) writes.

No NEWS entry: the cell API has not been released.

setcchar() takes a NUL-terminated string, so a NUL in a cell dropped the
rest of it: complexchar('a\0' + combining) kept only 'a', and an empty cell
read back as complexchar('') rather than complexchar('\0') as on a narrow
build.  Reject a NUL among other characters, read an empty cell as a NUL,
and give a NUL its own cell in complexstr().
A NUL cell ends a batch write and a cell array read (add_wchnstr(3X)), so
addstr() would write only the cells before it and in_wchstr() would read
only those, on both a wide and a narrow build.  addstr() already rejects an
embedded NUL in a str.
@serhiy-storchaka
serhiy-storchaka merged commit 9c48dfe into python:main Aug 21, 2026
51 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the fix-155877-nul branch August 21, 2026 15:54
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