Skip to content

Commit ccdf6a4

Browse files
gh-152275: Initialize the optional attr argument to zero
The attr converter had no C default, so for methods where attr is an optional argument (addch(), addstr(), insch(), ...) the generated code left the attr_t variable uninitialized when the argument was omitted. A garbage value was then applied as character attributes, corrupting the output on platforms where the stack did not happen to be zero. Give the converter a default of 0, as the previous long converter had. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7dd5e94 commit ccdf6a4

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

Modules/_cursesmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,9 @@ attr_converter(PyObject *arg, void *ptr)
931931
class attr_converter(CConverter):
932932
type = 'attr_t'
933933
converter = 'attr_converter'
934+
c_default = '0'
934935
[python start generated code]*/
935-
/*[python end generated code: output=da39a3ee5e6b4b0d input=6132d3d99d3ec25a]*/
936+
/*[python end generated code: output=da39a3ee5e6b4b0d input=1e97aef32b7ed469]*/
936937

937938
#ifdef HAVE_NCURSESW
938939
/* -------------------------------------------------------*/

Modules/clinic/_cursesmodule.c.h

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)