summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/common/sprintf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/firmware/common/sprintf.c b/firmware/common/sprintf.c
index 00084ac..6542c9d 100644
--- a/firmware/common/sprintf.c
+++ b/firmware/common/sprintf.c
@@ -154,7 +154,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_end(ap);
/* make sure it ends with a trailing zero */
- pr.ptr[ok?0:-1]='\0';
+ pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
return pr.bytes;
}
@@ -171,7 +171,7 @@ int vsnprintf(char *buf, int size, const char *fmt, va_list ap)
ok = format(sprfunc, &pr, fmt, ap);
/* make sure it ends with a trailing zero */
- pr.ptr[ok?0:-1]='\0';
+ pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
return pr.bytes;
}