From 0e4e69e52ec275370c3555bc18eb0a2d06b40898 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 27 Sep 2015 11:56:38 -0300 Subject: [PATCH] os/input: Don't advance past incomplete sequences in input_enqueue This allows callers to incrementally process buffers that are filled by incomplete chunks more easily. --- src/nvim/os/input.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 09f162f79d..e2cff2f9c0 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -171,10 +171,17 @@ size_t input_enqueue(String keys) } if (*ptr == '<') { - // Invalid key sequence, skip until the next '>' or until *end + char *old_ptr = ptr; + // Invalid or incomplete key sequence, skip until the next '>' or until + // *end do { ptr++; } while (ptr < end && *ptr != '>'); + if (*ptr != '>') { + // Incomplete key sequence, return without consuming. + ptr = old_ptr; + break; + } ptr++; continue; }