summaryrefslogtreecommitdiff
path: root/firmware/common/sprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/sprintf.c')
-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 00084acf0a..6542c9d993 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, ...)
154 va_end(ap); 154 va_end(ap);
155 155
156 /* make sure it ends with a trailing zero */ 156 /* make sure it ends with a trailing zero */
157 pr.ptr[ok?0:-1]='\0'; 157 pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
158 158
159 return pr.bytes; 159 return pr.bytes;
160} 160}
@@ -171,7 +171,7 @@ int vsnprintf(char *buf, int size, const char *fmt, va_list ap)
171 ok = format(sprfunc, &pr, fmt, ap); 171 ok = format(sprfunc, &pr, fmt, ap);
172 172
173 /* make sure it ends with a trailing zero */ 173 /* make sure it ends with a trailing zero */
174 pr.ptr[ok?0:-1]='\0'; 174 pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
175 175
176 return pr.bytes; 176 return pr.bytes;
177} 177}