diff options
author | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-25 13:24:22 -0300 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-25 13:24:22 -0300 |
commit | ba95aed6f1067dc577d8813625233982157167d9 (patch) | |
tree | cf88790ee13bc2bcbf4d33befb3362ea61451054 /osdep/getch2.c | |
parent | 1aa0ad2725d4421b007db0e604e7f7a624069925 (diff) | |
download | mpv-ba95aed6f1067dc577d8813625233982157167d9.tar.bz2 mpv-ba95aed6f1067dc577d8813625233982157167d9.tar.xz |
getch2: Avoid possible infinite loop
If the first character is not a valid UTF-8 start code nor is in termcap,
getch2 would enter an infinite loop. Always walk 1 byte in the UTF-8 case
unless it's a valid start code.
Diffstat (limited to 'osdep/getch2.c')
-rw-r--r-- | osdep/getch2.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c index c19a410252..e2ff398560 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -385,11 +385,11 @@ bool getch2(struct input_ctx *input_ctx) if (utf8_len > 1) { state = STATE_UTF8; - } else if (utf8_len == 1) { + continue; + } else if (utf8_len == 1) mp_input_put_key(input_ctx, c); - walk_buf(1); - } else - walk_buf(getch2_pos); + + walk_buf(1); break; } |