Skip to content

Commit d546545

Browse files
tejlmandjserv
authored andcommitted
Handle NULL character as input properly
Fixes: zephyrproject-rtos/zephyr#33212 Ignoring when user inputs NULL in a text field. menuconfig exits with a python stack trace if NULL is provided as input character, therefore ignore NULL as an input character to prevent this behaviour. A NULL character may be given accidentally by the user through the following ways: - Pressing `Win` key on keyboard (Windows only) - Pressing `<CTRL>-@` / `<CTRL>-2`. Signed-off-by: Torsten Rasmussen <[email protected]> Signed-off-by: Jim Huang <[email protected]>
1 parent 121c88e commit d546545

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

menuconfig.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,9 @@ def edit_width():
17621762
_safe_curs_set(0)
17631763
return None
17641764

1765+
elif c == "\0": # \0 = NUL, ignore
1766+
pass
1767+
17651768
else:
17661769
s, i, hscroll = _edit_text(c, s, i, hscroll, edit_width())
17671770

@@ -2201,6 +2204,9 @@ def select_prev_match():
22012204
elif c == curses.KEY_HOME:
22022205
sel_node_i = scroll = 0
22032206

2207+
elif c == "\0": # \0 = NUL, ignore
2208+
pass
2209+
22042210
else:
22052211
s, s_i, hscroll = _edit_text(c, s, s_i, hscroll,
22062212
_width(edit_box) - 2)

0 commit comments

Comments
 (0)