In case of a partial match (cases where buf is shorter than template) the loop was comparing one character too much, ending up with comparing \0 in buf which would fail. Fix: change pos++ to ++pos
The incrementation of the template counter has to be done always, so the conditions in the loop need to be switched. This problem was probably mostly unnoticed, since usually the whole sequence is read from the tty in a single buffer. However for example on Cygwin the buffer is read byte by byte and the bug surfaced. --- xterm-keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xterm-keys.c b/xterm-keys.c index 8c88587..6916552 100644 --- a/xterm-keys.c +++ b/xterm-keys.c @@ -133,7 +133,7 @@ xterm_keys_match(const char *template, const char *buf, size_t len) do { if (*template != '_' && buf[pos] != *template) return (-1); - } while (pos++ != len && *++template != '\0'); + } while (*++template != '\0' && ++pos != len); if (*template != '\0') /* partial */ return (1); -- 1.8.5.rc3 ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users