diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-10-30 23:58:29 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-10-31 00:00:30 +0100 |
commit | ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3 (patch) | |
tree | 623db7a6453e07d073f776ef37545430e131c823 /termo.c | |
parent | 2a351b150dbe133037afffef01375c39aacd9d74 (diff) | |
download | termo-ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3.tar.gz termo-ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3.tar.xz termo-ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3.zip |
Fix error handling in termo_strfkey()
If in any case snprintf() returned a negative value,
we would mishandle it.
Diffstat (limited to 'termo.c')
-rw-r--r-- | termo.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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; |