From ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Fri, 30 Oct 2015 23:58:29 +0100 Subject: Fix error handling in termo_strfkey() If in any case snprintf() returned a negative value, we would mishandle it. --- README.adoc | 1 + termo.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index ce63059..ba458c0 100644 --- a/README.adoc +++ b/README.adoc @@ -5,6 +5,7 @@ termo input. ncurses does a really terrible job at that, mainly wrt. mouse support which seems to be utterly broken. If you can drag things in a terminal application, such as in VIM, I can assure you it's not using ncurses for that. +(At least not with ncurses older than 6.0.) Since terminal I/O is really complicated and full of special cases, this project doesn't aspire to also replace the output part of ncurses, but is rather diff --git a/termo.c b/termo.c index 704116b..38caba2 100644 --- a/termo.c +++ b/termo.c @@ -1444,7 +1444,7 @@ termo_strfkey (termo_t *tk, char *buffer, size_t len, termo_key_t *key, termo_format_t format) { size_t pos = 0; - size_t l = 0; + int l = 0; struct modnames *mods = &modnames[ !!(format & TERMO_FORMAT_LONGMOD) + @@ -1477,7 +1477,7 @@ termo_strfkey (termo_t *tk, char *buffer, size_t len, { l = snprintf (buffer + pos, len - pos, wrapbracket ? "<^%c>" : "^%c", (char) codepoint); - if(l <= 0) + if (l <= 0) return pos; pos += l; return pos; -- cgit v1.2.3-70-g09d2