From d0b3b36a72dcd058687b0018f2b4b82d21e768bb Mon Sep 17 00:00:00 2001 From: Andreas Kupries Date: Fri, 18 Oct 2013 13:38:07 -0700 Subject: [PATCH] Bug fix. Ensure that current->cols is initialized Even when both stdin/stdout are redirected (which prevents the raw mode from getting set). --- linenoise.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linenoise.c b/linenoise.c index 7c6eb99..87513cc 100644 --- a/linenoise.c +++ b/linenoise.c @@ -221,6 +221,7 @@ static int enableRawMode(struct current *current) { struct termios raw; current->fd = STDIN_FILENO; + current->cols = 0; if (!isatty(current->fd) || isUnsupportedTerm() || tcgetattr(current->fd, &orig_termios) == -1) { @@ -254,8 +255,6 @@ fatal: goto fatal; } rawmode = 1; - - current->cols = 0; return 0; } -- 2.44.0