Fix error handling in termo_strfkey()

If in any case snprintf() returned a negative value,
we would mishandle it.
This commit is contained in:
2015-10-30 23:58:29 +01:00
parent 2a351b150d
commit ef29b7587d
2 changed files with 3 additions and 2 deletions

View File

@@ -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;