From 4ce39df38f79e5c078d95d46d71d8135bf713c17 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 4 May 2016 12:53:20 -0600 Subject: [PATCH] In io_callback() if we write the complete buffer and find that there is no associated reader just return as there is nothing else to be done. In practice is it not possible for SUDO_EV_READ to be set if revent is NULL but an early return is harmless and possibly easier to understand. Coverity CID 104124. --- src/exec_pty.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/exec_pty.c b/src/exec_pty.c index 359dde255..6ae587177 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -592,10 +592,11 @@ io_callback(int fd, int what, void *v) /* Reset buffer if fully consumed. */ if (iob->off == iob->len) { iob->off = iob->len = 0; - /* Forward the EOF from reader to writer. */ + /* If reader is gone, close and remove writer; we are done. */ if (iob->revent == NULL) { safe_close(fd); ev_free_by_fd(evbase, fd); + debug_return; } } /* Re-enable writer if buffer is not empty. */ -- 2.40.0