summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-30 20:54:23 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-30 20:54:23 (GMT)
commite1ac09d1370025a1dd10546fae68d1616cf15346 (patch)
tree76648432e0f4d2eeefef77660844cab09edafc17 /Modules
parent3e7f593c8789afc59b10eeb92683e2bd093c5f71 (diff)
parenta0d9c685d0c3f817c5a7143098ce1a89380ee514 (diff)
downloadcpython-e1ac09d1370025a1dd10546fae68d1616cf15346.zip
cpython-e1ac09d1370025a1dd10546fae68d1616cf15346.tar.gz
cpython-e1ac09d1370025a1dd10546fae68d1616cf15346.tar.bz2
Issue #28549: Fixed segfault in curses's addch() with ncurses6.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_cursesmodule.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index e63c16c..3bf2ca7 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -280,7 +280,7 @@ static int
PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
chtype *ch
#ifdef HAVE_NCURSESW
- , cchar_t *wch
+ , wchar_t *wch
#endif
)
{
@@ -298,8 +298,7 @@ PyCurses_ConvertToCchar_t(PyCursesWindowObject *win, PyObject *obj,
PyUnicode_GET_LENGTH(obj));
return 0;
}
- memset(wch->chars, 0, sizeof(wch->chars));
- wch->chars[0] = buffer[0];
+ *wch = buffer[0];
return 2;
#else
return PyCurses_ConvertToChtype(win, obj, ch);
@@ -597,7 +596,8 @@ curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y,
int type;
chtype cch;
#ifdef HAVE_NCURSESW
- cchar_t wch;
+ wchar_t wstr[2];
+ cchar_t wcval;
#endif
const char *funcname;
@@ -605,14 +605,15 @@ curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y,
attr = A_NORMAL;
#ifdef HAVE_NCURSESW
- type = PyCurses_ConvertToCchar_t(cwself, ch, &cch, &wch);
+ type = PyCurses_ConvertToCchar_t(cwself, ch, &cch, wstr);
if (type == 2) {
funcname = "add_wch";
- wch.attr = attr;
+ wstr[1] = L'\0';
+ setcchar(&wcval, wstr, attr, 0, NULL);
if (coordinates_group)
- rtn = mvwadd_wch(cwself->win,y,x, &wch);
+ rtn = mvwadd_wch(cwself->win,y,x, &wcval);
else {
- rtn = wadd_wch(cwself->win, &wch);
+ rtn = wadd_wch(cwself->win, &wcval);
}
}
else