Bug description:
window.in_wstr(y, x, 0) reads uninitialized heap memory. winnwstr() only writes the
terminating null when it stored at least one character, but the buffer comes from
PyMem_New and the result is read with PyUnicode_FromWideChar(buf, -1), which scans for
that null (Modules/_cursesmodule.c:3853, :3869). The value differs on every run:
in_wstr(0, 0, 0) -> ValueError: character U+e7180240 is not in range [U+0000; U+10ffff]
in_wstr(0, 0, 0) -> ValueError: character U+20b80240 is not in range [U+0000; U+10ffff]
instr(0, 0, 0) and in_wchstr(0, 0, 0) correctly return b'' and
curses.complexstr([]).
gh-152503 fixed this for in_wch(), in_wchstr() and getbkgrnd(); in_wstr() was
missed, and unlike those it reproduces on stock ncursesw. It is new in 3.16 (gh-151757), so
no released version is affected.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug description:
window.in_wstr(y, x, 0)reads uninitialized heap memory.winnwstr()only writes theterminating null when it stored at least one character, but the buffer comes from
PyMem_Newand the result is read withPyUnicode_FromWideChar(buf, -1), which scans forthat null (
Modules/_cursesmodule.c:3853,:3869). The value differs on every run:instr(0, 0, 0)andin_wchstr(0, 0, 0)correctly returnb''andcurses.complexstr([]).gh-152503 fixed this for
in_wch(),in_wchstr()andgetbkgrnd();in_wstr()wasmissed, and unlike those it reproduces on stock ncursesw. It is new in 3.16 (gh-151757), so
no released version is affected.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs