billiob pushed a commit to branch terminology-1.6.

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

commit a782ce61e2260431d4ecd878a3b8f48c9b609c75
Author: Boris Faure <bill...@gmail.com>
Date:   Thu Dec 5 19:08:05 2019 +0100

    test return of ty_sb_add(). Closes CID1408482
---
 src/bin/termiointernals.c | 16 ++++++++++++++--
 src/bin/termpty.c         | 18 +++++++++++++-----
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/bin/termiointernals.c b/src/bin/termiointernals.c
index 598c724..3d7c501 100644
--- a/src/bin/termiointernals.c
+++ b/src/bin/termiointernals.c
@@ -414,9 +414,21 @@ termio_internal_get_selection(Termio *sd, size_t *lenp)
 
              if (isb.len)
                {
+                  int res;
                   if (isb.buf[isb.len - 1] != '\n' && i != end_y)
-                    ty_sb_add(&isb, "\n", 1);
-                  ty_sb_add(&sb, isb.buf, isb.len);
+                    {
+                       res = ty_sb_add(&isb, "\n", 1);
+                       if (res < 0)
+                         {
+                            ERR("failure to add newline to selection buffer");
+                         }
+                    }
+                  res = ty_sb_add(&sb, isb.buf, isb.len);
+                  if (res < 0)
+                    {
+                       ERR("failure to add %zd characters to selection buffer",
+                           isb.len);
+                    }
                }
              ty_sb_free(&isb);
           }
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 502aa90..480fc36 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1305,11 +1305,19 @@ termpty_write(Termpty *ty, const char *input, int len)
 #if defined(ENABLE_FUZZING)
    return;
 #endif
-   ty_sb_add(&ty->write_buffer, input, len);
-   ecore_main_fd_handler_active_set(ty->hand_fd,
-                                    ECORE_FD_ERROR |
-                                    ECORE_FD_READ |
-                                    ECORE_FD_WRITE);
+   int res = ty_sb_add(&ty->write_buffer, input, len);
+
+   if (res < 0)
+     {
+        ERR("failure to add %d characters to write buffer", len);
+     }
+   else
+     {
+        ecore_main_fd_handler_active_set(ty->hand_fd,
+                                         ECORE_FD_ERROR |
+                                         ECORE_FD_READ |
+                                         ECORE_FD_WRITE);
+     }
 }
 
 struct screen_info

-- 


Reply via email to