]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Make buf_append_utf16le() robust against being passed NULL
authorDavid Woodhouse <dwmw2@infradead.org>
Sat, 26 Feb 2022 14:55:49 +0000 (14:55 +0000)
committerDavid Woodhouse <dwmw2@infradead.org>
Sat, 26 Feb 2022 14:55:49 +0000 (14:55 +0000)
This should stop the crash in #370 slthough it would be good to know
precisely why it's happening.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
textbuf.c

index 760d36020c09e1b4ba7d78bdeff47bc1c42ce4b0..dafea6c8dc5ecd55a9b8f67fd088d8cee2e05532 100644 (file)
--- a/textbuf.c
+++ b/textbuf.c
@@ -287,6 +287,9 @@ int buf_append_utf16le(struct oc_text_buf *buf, const char *utf8)
 {
        int utfchar, len = 0;
 
+       if (!utf8)
+               return 0;
+
        /* Ick. Now I'm implementing my own UTF8 handling too. Perhaps it's
           time to bite the bullet and start requiring something like glib? */
        while (*utf8) {