[systemd-devel] [RFC][PATCH 2/2] terminal: handle term_utf8_decode returning NULL

philippedeswert at gmail.com philippedeswert at gmail.com
Sat Sep 13 02:24:54 PDT 2014


From: Philippe De Swert <philippedeswert at gmail.com>

term_utf8_decode can return NULL. We definitely do not want
to dereference ucs4_str in case this happens.
Not really sure on what to return or handle this though.
---
 src/libsystemd-terminal/term-screen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/libsystemd-terminal/term-screen.c b/src/libsystemd-terminal/term-screen.c
index 67f9056..5124db6 100644
--- a/src/libsystemd-terminal/term-screen.c
+++ b/src/libsystemd-terminal/term-screen.c
@@ -3757,6 +3757,8 @@ int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
          * enough to support old 7bit/8bit modes. */
         for (i = 0; i < size; ++i) {
                 ucs4_str = term_utf8_decode(&screen->utf8, &ucs4_len, in[i]);
+                if(!ucs4_str)
+                        return 0;
                 for (j = 0; j < ucs4_len; ++j) {
                         r = term_parser_feed(screen->parser, &seq, ucs4_str[j]);
                         if (r < 0) {
-- 
1.8.3.2



More information about the systemd-devel mailing list