aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2016-12-05 22:45:44 +0100
committerBoris Faure <billiob@gmail.com>2016-12-05 22:45:44 +0100
commit7508c8658b71d7151892ff7a9347c77348a64afc (patch)
tree585464c7bf58426de51fa2e2447c111b790c975d
parenttermpty: fix dead code and remove debugging code. CID1366815 (diff)
downloadterminology-7508c8658b71d7151892ff7a9347c77348a64afc.tar.gz
termpty: ensure we're not reading from invalid fd
-rw-r--r--src/bin/termpty.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 57398fb..476c1d0 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -169,6 +169,8 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
ERR("error while reading from tty slave fd");
return ECORE_CALLBACK_CANCEL;
}
+ if (ty->fd == -1)
+ return ECORE_CALLBACK_CANCEL;
// read up to 64 * 4096 bytes
for (reads = 0; reads < 64; reads++)
@@ -190,6 +192,10 @@ _cb_fd_read(void *data, Ecore_Fd_Handler *fd_handler)
{
ERR("error while reading from tty slave fd: %s", strerror(errno));
}
+ close(ty->fd);
+ ty->fd = -1;
+ if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
+ ty->hand_fd = NULL;
return ECORE_CALLBACK_CANCEL;
}
if (len <= 0) break;
@@ -584,7 +590,11 @@ termpty_free(Termpty *ty)
if (ty->block.blocks) eina_hash_free(ty->block.blocks);
if (ty->block.chid_map) eina_hash_free(ty->block.chid_map);
if (ty->block.active) eina_list_free(ty->block.active);
- if (ty->fd >= 0) close(ty->fd);
+ if (ty->fd >= 0)
+ {
+ close(ty->fd);
+ ty->fd = -1;
+ }
if (ty->slavefd >= 0) close(ty->slavefd);
if (ty->pid >= 0)
{