vis

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

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

commit 3d393602e6db208e6de5d6fac316ac0bcd7e0f6a
parent c7db75a692b398523268f66ebae5b027434f8c91
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed,  5 Oct 2016 20:11:13 +0200

vis: check return value of fcntl(2) call

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

diff --git a/vis.c b/vis.c @@ -1312,9 +1312,9 @@ int vis_pipe(Vis *vis, Filerange *range, bool interactive, const char *argv[], close(pout[1]); close(perr[1]); - fcntl(pout[0], F_SETFL, O_NONBLOCK); - fcntl(perr[0], F_SETFL, O_NONBLOCK); - + if (fcntl(pout[0], F_SETFL, O_NONBLOCK) == -1 || + fcntl(perr[0], F_SETFL, O_NONBLOCK) == -1) + goto err; fd_set rfds, wfds; @@ -1393,6 +1393,7 @@ int vis_pipe(Vis *vis, Filerange *range, bool interactive, const char *argv[], } while (pin[1] != -1 || pout[0] != -1 || perr[0] != -1); +err: if (pin[1] != -1) close(pin[1]); if (pout[0] != -1)