diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-11-01 06:58:18 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-11-01 06:58:18 -0700 |
commit | b8e093dbaae99d2dc12157fcce1bb12ba26b8d3e (patch) | |
tree | f3b3d678a1e0b67b3688f9b97ebffc7c83d9b512 /linenoise | |
parent | 0aa0c547cd586ad2871bbb9487dcde0ac5bf273b (diff) | |
download | txr-b8e093dbaae99d2dc12157fcce1bb12ba26b8d3e.tar.gz txr-b8e093dbaae99d2dc12157fcce1bb12ba26b8d3e.tar.bz2 txr-b8e093dbaae99d2dc12157fcce1bb12ba26b8d3e.zip |
linenoise: guard against setting cols to zero.
* linenoise/linenoise.c (get_columns): Avoid the situation
that cols is zero or negative. The cols value is involved in a
modulo calculation (position % cols), which requires cols not
to be zero. The situation hasn't been observed; this is just
defensive coding.
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 3aaf7b80..f3784597 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -342,7 +342,7 @@ static int get_columns(mem_t *ifs, mem_t *ofs) { if (!lino_os.puts_fn(ofs, L"\x1b[999C")) goto failed; cols = get_cursor_position(ifs, ofs); - if (cols == -1) goto failed; + if (cols <= 0) goto failed; /* Restore position. */ if (cols > start) { |