Skip to content

Commit 3559630

Browse files
fix sprintf and vsprintf
1 parent 218dd5a commit 3559630

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libc/nanoprintf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <stdint.h>
4848
#include <stddef.h>
4949
#include <stdio.h>
50+
#include <limits.h>
5051

5152
// Pick reasonable defaults if nothing's been configured.
5253
#if !defined(NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS) && \
@@ -1013,7 +1014,7 @@ int _snprintf_c(char *buffer, size_t bufsz, const char *format, ...) {
10131014

10141015
int _vsprintf_c(char *buffer, const char *format, va_list vlist)
10151016
{
1016-
return vsnprintf(buffer, (size_t)-1, format, vlist);
1017+
return vsnprintf(buffer, (size_t)INT_MAX, format, vlist);
10171018
}
10181019

10191020
int _vprintf_c(const char *format, va_list vlist)
@@ -1025,7 +1026,7 @@ int _sprintf_c(char *buffer, const char *format, ...)
10251026
{
10261027
va_list va;
10271028
va_start(va, format);
1028-
const int ret = vsnprintf(buffer, (size_t)-1, format, va);
1029+
const int ret = vsnprintf(buffer, (size_t)INT_MAX, format, va);
10291030
va_end(va);
10301031
return ret;
10311032
}

0 commit comments

Comments
 (0)