ui/curses: Fix infinite loop on windows
Replace -1 comparisons for wint_t with WEOF to fix infinite loop caused by a 65535 == -1 comparison. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2905 Signed-off-by: William Hu <purplearmadillo77@proton.me> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [ Marc-André - Add missing similar code change, remove a comment ] Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <tSO5to8--iex6QMThG3Z8ElfnNOUahK_yitw2G2tEVRPoMKV936CBdrpyfbeNpVEpziKqeQ1ShBwPOoDkofgApM8YWwnPKJR_JrPDThV8Bc=@proton.me>
This commit is contained in:
parent
e0006a8661
commit
c7ac771ee7
1 changed files with 6 additions and 4 deletions
10
ui/curses.c
10
ui/curses.c
|
|
@ -265,7 +265,8 @@ static int curses2foo(const int _curses2foo[], const int _curseskey2foo[],
|
||||||
|
|
||||||
static void curses_refresh(DisplayChangeListener *dcl)
|
static void curses_refresh(DisplayChangeListener *dcl)
|
||||||
{
|
{
|
||||||
int chr, keysym, keycode, keycode_alt;
|
wint_t chr = 0;
|
||||||
|
int keysym, keycode, keycode_alt;
|
||||||
enum maybe_keycode maybe_keycode = CURSES_KEYCODE;
|
enum maybe_keycode maybe_keycode = CURSES_KEYCODE;
|
||||||
|
|
||||||
curses_winch_check();
|
curses_winch_check();
|
||||||
|
|
@ -284,8 +285,9 @@ static void curses_refresh(DisplayChangeListener *dcl)
|
||||||
/* while there are any pending key strokes to process */
|
/* while there are any pending key strokes to process */
|
||||||
chr = console_getch(&maybe_keycode);
|
chr = console_getch(&maybe_keycode);
|
||||||
|
|
||||||
if (chr == -1)
|
if (chr == WEOF) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef KEY_RESIZE
|
#ifdef KEY_RESIZE
|
||||||
/* this shouldn't occur when we use a custom SIGWINCH handler */
|
/* this shouldn't occur when we use a custom SIGWINCH handler */
|
||||||
|
|
@ -304,9 +306,9 @@ static void curses_refresh(DisplayChangeListener *dcl)
|
||||||
/* alt or esc key */
|
/* alt or esc key */
|
||||||
if (keycode == 1) {
|
if (keycode == 1) {
|
||||||
enum maybe_keycode next_maybe_keycode = CURSES_KEYCODE;
|
enum maybe_keycode next_maybe_keycode = CURSES_KEYCODE;
|
||||||
int nextchr = console_getch(&next_maybe_keycode);
|
wint_t nextchr = console_getch(&next_maybe_keycode);
|
||||||
|
|
||||||
if (nextchr != -1) {
|
if (nextchr != WEOF) {
|
||||||
chr = nextchr;
|
chr = nextchr;
|
||||||
maybe_keycode = next_maybe_keycode;
|
maybe_keycode = next_maybe_keycode;
|
||||||
keycode_alt = ALT;
|
keycode_alt = ALT;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue