vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 95038a46a1a9ef6665aeb4ccc820c7cae67973e3
parent 199728ac0e15a7128bd9c4c0a01239dd23996709
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 30 Jun 2015 13:47:28 +0200

Fix segfault in cmd_filter

Using FD_ISSET on negative file descriptors results in breakage.

Closes #55.

Diffstat:
Mvis.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vis.c b/vis.c @@ -1779,7 +1779,7 @@ static bool cmd_filter(Filerange *range, enum CmdOpt opt, const char *argv[]) { break; } - if (FD_ISSET(pin[1], &wfds)) { + if (pin[1] != -1 && FD_ISSET(pin[1], &wfds)) { Filerange junk = *range; if (junk.end > junk.start + PIPE_BUF) junk.end = junk.start + PIPE_BUF; @@ -1798,7 +1798,7 @@ static bool cmd_filter(Filerange *range, enum CmdOpt opt, const char *argv[]) { } } - if (FD_ISSET(pout[0], &rfds)) { + if (pout[0] != -1 && FD_ISSET(pout[0], &rfds)) { char buf[BUFSIZ]; ssize_t len = read(pout[0], buf, sizeof buf); if (len > 0) { @@ -1814,7 +1814,7 @@ static bool cmd_filter(Filerange *range, enum CmdOpt opt, const char *argv[]) { } } - if (FD_ISSET(perr[0], &rfds)) { + if (perr[0] != -1 && FD_ISSET(perr[0], &rfds)) { char buf[BUFSIZ]; ssize_t len = read(perr[0], buf, sizeof buf); if (len > 0) {