aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-06-30 13:47:28 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-06-30 13:47:28 +0200
commit860ad58af0e1c39d5ffda0474ed3c58aaa1ecca5 (patch)
treef677ac66a11a0517aa2d8afd36c1f948cf625547 /vis.c
parent4af9fe66851a42c20c550f2c59aa64d7a327c9ff (diff)
downloadvis-860ad58af0e1c39d5ffda0474ed3c58aaa1ecca5.tar.gz
vis-860ad58af0e1c39d5ffda0474ed3c58aaa1ecca5.tar.xz
Fix segfault in cmd_filter
Using FD_ISSET on negative file descriptors results in breakage. Closes #55.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/vis.c b/vis.c
index 34f8837..63c574e 100644
--- 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) {