billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=a119ac10cc0a98ac26cfbb2ab66b034299350bc1

commit a119ac10cc0a98ac26cfbb2ab66b034299350bc1
Author: Boris Faure <[email protected]>
Date:   Sun Apr 5 15:49:26 2020 +0200

    tycat/tyls: handle error on write()/scanf()
---
 src/bin/tycat.c |  6 +++++-
 src/bin/tyls.c  | 10 +++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/bin/tycat.c b/src/bin/tycat.c
index 1a618c0..d9a10ef 100644
--- a/src/bin/tycat.c
+++ b/src/bin/tycat.c
@@ -337,7 +337,11 @@ main(int argc, char **argv)
    echo_off();
    snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
    if (ty_write(1, buf, strlen(buf) + 1) < 0)
-     perror("write");
+     {
+        perror("write");
+        echo_on();
+        goto shutdown;
+     }
    if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4 ||
        ((tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1)))
      {
diff --git a/src/bin/tyls.c b/src/bin/tyls.c
index aa9a20d..8c0c190 100644
--- a/src/bin/tyls.c
+++ b/src/bin/tyls.c
@@ -760,18 +760,22 @@ main(int argc, char **argv)
         int i, cw, ch;
         int len;
         char *rp;
-        
+
         evas = ecore_evas_get(ee);
         echo_off();
         snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
         len = strlen(buf);
         if (ty_write(1, buf, len + 1) < (signed)len + 1)
-          perror("write");
+          {
+             perror("write");
+             echo_on();
+             return -1;
+          }
         if ((scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4)
             || (tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
           {
              echo_on();
-             return 0;
+             return -1;
           }
         echo_on();
         for (i = 1; i < argc; i++)

-- 


Reply via email to